Add command line flag to cgr-engine for logging levels

This adds a new -log_level flag to cgr-engine, defaulting to 5 (INFO). The logger has been extended to drop log messages that do not meet or exceed the log level requested.
This commit is contained in:
Shane Neuerburg
2016-10-21 19:31:24 -06:00
parent 3bd6ec39bd
commit 6c05c42c44
5 changed files with 118 additions and 17 deletions

View File

@@ -66,6 +66,7 @@ var (
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
scheduledShutdown = flag.String("scheduled_shutdown", "", "shutdown the engine after this duration")
singlecpu = flag.Bool("singlecpu", false, "Run on single CPU core")
logLevel = flag.Int("log_level", 8, "Log level (2-alert to 9-debug)")
cfg *config.CGRConfig
smRpc *v1.SessionManagerV1
@@ -568,6 +569,7 @@ func main() {
exitChan <- true
}()
}
utils.Logger.SetLogLevel(*logLevel)
cfg, err = config.NewCGRConfigFromFolder(*cfgDir)
if err != nil {
utils.Logger.Crit(fmt.Sprintf("Could not parse config: %s exiting!", err))