diff --git a/CHANGELOG.md b/CHANGELOG.md index 568a486..f428b19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Releases +## Release v0.0.9 + +* Implemented new config parameter --logLevel +* Dependencies updated + ## Release v0.0.8 * Fixed golang version in github actions pipeline diff --git a/README.md b/README.md index 5eb07a3..997982a 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,6 @@ go tool pprof http://127.0.0.1:8080/debug/pprof/goroutine # terminal 2, for mq-to-db-02 inside the docker-compose-file go tool pprof http://127.0.0.1:8081/debug/pprof/goroutine - # once you are into tool pprof, execute the command web (pprof) web ``` diff --git a/cmd/mq-to-db/main.go b/cmd/mq-to-db/main.go index 65243fc..65f5ea9 100644 --- a/cmd/mq-to-db/main.go +++ b/cmd/mq-to-db/main.go @@ -82,9 +82,12 @@ func init() { // package initializer flag.BoolVar(&conf.Server.KeepAlivesEnabled, "server.keepAlivesEnabled", true, "Server KeepAlivesEnabled") flag.BoolVar(&conf.Server.Debug, "debug", false, "debug") flag.BoolVar(&conf.Server.Profile, "profile", false, "Enable program profile") - flag.StringVar(&conf.Server.LogFormat, "logFormat", "text", "Log Format [text|json] ") + flag.StringVar(&conf.Server.LogFormat, "logFormat", "text", "Log Format [text|json]") + flag.StringVar(&conf.Server.LogLevel, "logLevel", "info", "Log Level [debug|info|warning|panic|fatal]") + // Application conf flags flag.StringVar(&conf.Application.ConfigFile, "configFile", "config", "Configuration file") + // Application version flags showVersion := flag.Bool("version", false, "Show application version") showVersionInfo := flag.Bool("versionInfo", false, "Show application version information") @@ -118,12 +121,26 @@ func init() { // package initializer log.SetFormatter(&logrus.TextFormatter{DisableColors: false, DisableTimestamp: false, FullTimestamp: true}) } - if conf.Server.Debug { + switch conf.Server.LogLevel { + case "debug": log.SetLevel(logrus.DebugLevel) - } else { + case "info": + log.SetLevel(logrus.InfoLevel) + case "warning": + log.SetLevel(logrus.WarnLevel) + case "panic": + log.SetLevel(logrus.PanicLevel) + case "fatal": + log.SetLevel(logrus.FatalLevel) + default: log.SetLevel(logrus.InfoLevel) } + // if --debug, force debug log level no matter what value is in logLevel + if conf.Server.Debug { + log.SetLevel(logrus.DebugLevel) + } + log.Info("Application initialized") } @@ -652,7 +669,7 @@ func HomePage(w http.ResponseWriter, r *http.Request) {
- +