1
0
Fork 0
mirror of https://github.com/Luzifer/share.git synced 2024-10-18 05:14:23 +00:00

Allow specifying log-level

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-10-19 23:40:42 +02:00
parent 7572dcdff6
commit 9d323a1044
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -24,6 +24,7 @@ var (
ContentType string `flag:"content-type,c" vardefault:"file_template" description:"Force content-type to be set to this value"`
FileTemplate string `flag:"file-template" default:"" description:"Full name template of the uploaded file"`
Listen string `flag:"listen" default:"" description:"Enable HTTP server if set to IP/Port (e.g. ':3000')"`
LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warn, error, fatal)"`
Progress bool `flag:"progress" default:"false" description:"Show progress bar while uploading"`
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
}{}
@ -49,6 +50,12 @@ func initApp() {
os.Exit(0)
}
if l, err := log.ParseLevel(cfg.LogLevel); err != nil {
log.WithError(err).Fatal("Unable to parse log level")
} else {
log.SetLevel(l)
}
if cfg.BasePath != "" {
cfg.FileTemplate = strings.Join([]string{strings.TrimRight(cfg.BasePath, "/"), `{{ .SafeFileName }}`}, "/")
log.WithField("file-template", cfg.FileTemplate).Warn("Using deprecated base-path parameter! Using update file-template...")