Skip to content

Commit 81ac648

Browse files
committed
log: add all log-levels that are accepted
While other log-levels are not currently used in containerd itself, they can be returned by `GetLevel()`, and are accepted (no error) by `SetLevel()`. We should either accept those values, or produce an error (in `SetLevel()`), but given that there's other ways to set the log-level, we should probably acknowledge that this package is a transitional package, and still closely tied to logrus (for the time being). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 0b6333a commit 81ac648

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

log/context.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ const (
6060
// InfoLevel level. General operational entries about what's going on
6161
// inside the application.
6262
InfoLevel Level = logrus.InfoLevel
63+
64+
// WarnLevel level. Non-critical entries that deserve eyes.
65+
WarnLevel Level = logrus.WarnLevel
66+
67+
// ErrorLevel level. Logs errors that should definitely be noted.
68+
// Commonly used for hooks to send errors to an error tracking service.
69+
ErrorLevel Level = logrus.ErrorLevel
70+
71+
// FatalLevel level. Logs and then calls "logger.Exit(1)". It exits
72+
// even if the logging level is set to Panic.
73+
FatalLevel Level = logrus.FatalLevel
74+
75+
// PanicLevel level. This is the highest level of severity. Logs and
76+
// then calls panic with the message passed to Debug, Info, ...
77+
PanicLevel Level = logrus.PanicLevel
6378
)
6479

6580
// SetLevel sets log level globally. It returns an error if the given
@@ -70,6 +85,10 @@ const (
7085
// - "trace" ([TraceLevel])
7186
// - "debug" ([DebugLevel])
7287
// - "info" ([InfoLevel])
88+
// - "warn" ([WarnLevel])
89+
// - "error" ([ErrorLevel])
90+
// - "fatal" ([FatalLevel])
91+
// - "panic" ([PanicLevel])
7392
func SetLevel(level string) error {
7493
lvl, err := logrus.ParseLevel(level)
7594
if err != nil {

0 commit comments

Comments
 (0)