Made log level configurable

#7
This commit is contained in:
Philipp Häfelfinger 2019-03-03 23:34:11 +01:00
parent 48a89da9a6
commit 084b3a3e2b
2 changed files with 14 additions and 2 deletions

View File

@ -1,12 +1,17 @@
package main package main
import ( import (
"flag"
"git.haefelfinger.net/piwigo/DirectoriesToAlbums/internal/app" "git.haefelfinger.net/piwigo/DirectoriesToAlbums/internal/app"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vharitonsky/iniflags" "github.com/vharitonsky/iniflags"
"os" "os"
) )
var (
logLevel = flag.String("logLevel", "info", "The minimum log level required to write out a log message. (panic,fatal,error,warn,info,debug,trace)")
)
func main() { func main() {
iniflags.Parse() iniflags.Parse()
initializeLog() initializeLog()
@ -14,8 +19,13 @@ func main() {
} }
func initializeLog() { func initializeLog() {
//TODO: make log configurable to file instead of console level, err := logrus.ParseLevel(*logLevel)
logrus.SetLevel(logrus.DebugLevel) if err != nil {
level = logrus.DebugLevel
}
logrus.SetLevel(level)
logrus.SetOutput(os.Stdout) logrus.SetOutput(os.Stdout)
logrus.Infoln("Starting Piwigo directories to albums...") logrus.Infoln("Starting Piwigo directories to albums...")
} }

View File

@ -2,6 +2,8 @@ allowMissingConfig = false # Don't terminate the app if the ini file cannot be
allowUnknownFlags = false # Don't terminate the app if ini file contains unknown flags. allowUnknownFlags = false # Don't terminate the app if ini file contains unknown flags.
configUpdateInterval = 0s # Update interval for re-reading config file set via -config flag. Zero disables config file re-reading. configUpdateInterval = 0s # Update interval for re-reading config file set via -config flag. Zero disables config file re-reading.
imagesRootPath = # This is the images root path that should be mirrored to piwigo. imagesRootPath = # This is the images root path that should be mirrored to piwigo.
logLevel = info # The minimum log level required to write out a log message. (panic,fatal,error,warn,info,debug,trace)
piwigoPassword = # This is password to the given username. piwigoPassword = # This is password to the given username.
piwigoUploadChunkSizeInKB = 512 # The chunksize used to upload an image to piwigo.
piwigoUrl = # The root url without tailing slash to your piwigo installation. piwigoUrl = # The root url without tailing slash to your piwigo installation.
piwigoUser = # The username to use during sync. piwigoUser = # The username to use during sync.