mirror of
https://github.com/Luzifer/share.git
synced 2024-12-20 18:41:17 +00:00
Allow specifying log-level
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
7572dcdff6
commit
9d323a1044
1 changed files with 7 additions and 0 deletions
7
main.go
7
main.go
|
@ -24,6 +24,7 @@ var (
|
||||||
ContentType string `flag:"content-type,c" vardefault:"file_template" description:"Force content-type to be set to this value"`
|
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"`
|
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')"`
|
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"`
|
Progress bool `flag:"progress" default:"false" description:"Show progress bar while uploading"`
|
||||||
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
||||||
}{}
|
}{}
|
||||||
|
@ -49,6 +50,12 @@ func initApp() {
|
||||||
os.Exit(0)
|
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 != "" {
|
if cfg.BasePath != "" {
|
||||||
cfg.FileTemplate = strings.Join([]string{strings.TrimRight(cfg.BasePath, "/"), `{{ .SafeFileName }}`}, "/")
|
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...")
|
log.WithField("file-template", cfg.FileTemplate).Warn("Using deprecated base-path parameter! Using update file-template...")
|
||||||
|
|
Loading…
Reference in a new issue