Include log level option

This commit is contained in:
Rodrigo Brito 2019-03-13 11:04:43 -03:00 committed by Isaev Denis
parent 22c0580cc7
commit 099f2ae41a
3 changed files with 14 additions and 2 deletions

View File

@ -942,6 +942,7 @@ There is the most valuable changes log:
2. Build and test on go 1.12
3. Support `--color` option
4. Update x/tools to fix c++ issues
5. Include support to log level
### February 2019

View File

@ -491,6 +491,7 @@ There is the most valuable changes log:
2. Build and test on go 1.12
3. Support `--color` option
4. Update x/tools to fix c++ issues
5. Include support to log level
### February 2019

View File

@ -24,12 +24,22 @@ func NewStderrLog(name string) *StderrLog {
level: LogLevelWarn,
}
// control log level in logutils, not in logrus
switch os.Getenv("LOG_LEVEL") {
case "error", "err":
sl.logger.SetLevel(logrus.ErrorLevel)
case "warning", "warn":
sl.logger.SetLevel(logrus.WarnLevel)
case "info":
sl.logger.SetLevel(logrus.InfoLevel)
default:
sl.logger.SetLevel(logrus.DebugLevel)
}
sl.logger.Out = StdErr
sl.logger.Formatter = &logrus.TextFormatter{
DisableTimestamp: true, // `INFO[0007] msg` -> `INFO msg`
}
return sl
}