Skip to content

Commit

Permalink
log: add all log-levels that are accepted
Browse files Browse the repository at this point in the history
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 <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 30, 2023
1 parent 0b6333a commit 81ac648
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions log/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ const (
// InfoLevel level. General operational entries about what's going on
// inside the application.
InfoLevel Level = logrus.InfoLevel

// WarnLevel level. Non-critical entries that deserve eyes.
WarnLevel Level = logrus.WarnLevel

// ErrorLevel level. Logs errors that should definitely be noted.
// Commonly used for hooks to send errors to an error tracking service.
ErrorLevel Level = logrus.ErrorLevel

// FatalLevel level. Logs and then calls "logger.Exit(1)". It exits
// even if the logging level is set to Panic.
FatalLevel Level = logrus.FatalLevel

// PanicLevel level. This is the highest level of severity. Logs and
// then calls panic with the message passed to Debug, Info, ...
PanicLevel Level = logrus.PanicLevel
)

// SetLevel sets log level globally. It returns an error if the given
Expand All @@ -70,6 +85,10 @@ const (
// - "trace" ([TraceLevel])
// - "debug" ([DebugLevel])
// - "info" ([InfoLevel])
// - "warn" ([WarnLevel])
// - "error" ([ErrorLevel])
// - "fatal" ([FatalLevel])
// - "panic" ([PanicLevel])
func SetLevel(level string) error {
lvl, err := logrus.ParseLevel(level)
if err != nil {
Expand Down

0 comments on commit 81ac648

Please sign in to comment.