Skip to content

Commit 099f2ae

Browse files
rodrigo-britojirfag
authored andcommitted
Include log level option
1 parent 22c0580 commit 099f2ae

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ There is the most valuable changes log:
942942
2. Build and test on go 1.12
943943
3. Support `--color` option
944944
4. Update x/tools to fix c++ issues
945+
5. Include support to log level
945946
946947
### February 2019
947948

README.tmpl.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ There is the most valuable changes log:
491491
2. Build and test on go 1.12
492492
3. Support `--color` option
493493
4. Update x/tools to fix c++ issues
494+
5. Include support to log level
494495

495496
### February 2019
496497

pkg/logutils/stderr_log.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,22 @@ func NewStderrLog(name string) *StderrLog {
2424
level: LogLevelWarn,
2525
}
2626

27-
// control log level in logutils, not in logrus
28-
sl.logger.SetLevel(logrus.DebugLevel)
27+
switch os.Getenv("LOG_LEVEL") {
28+
case "error", "err":
29+
sl.logger.SetLevel(logrus.ErrorLevel)
30+
case "warning", "warn":
31+
sl.logger.SetLevel(logrus.WarnLevel)
32+
case "info":
33+
sl.logger.SetLevel(logrus.InfoLevel)
34+
default:
35+
sl.logger.SetLevel(logrus.DebugLevel)
36+
}
37+
2938
sl.logger.Out = StdErr
3039
sl.logger.Formatter = &logrus.TextFormatter{
3140
DisableTimestamp: true, // `INFO[0007] msg` -> `INFO msg`
3241
}
42+
3343
return sl
3444
}
3545

0 commit comments

Comments
 (0)