diff --git a/util/eventlog/context.go b/util/eventlog/context.go index 7073f3fc0..c11f47179 100644 --- a/util/eventlog/context.go +++ b/util/eventlog/context.go @@ -10,6 +10,9 @@ type key int const metadataKey key = 0 +// ContextWithLoggable returns a derived context which contains the provided +// Loggable. Any Events logged with the derived context will include the +// provided Loggable. func ContextWithLoggable(ctx context.Context, l Loggable) context.Context { existing, err := MetadataFromContext(ctx) if err != nil { diff --git a/util/eventlog/option.go b/util/eventlog/option.go index 563708f80..9ab80cb4c 100644 --- a/util/eventlog/option.go +++ b/util/eventlog/option.go @@ -19,17 +19,19 @@ func init() { type Option func() +// Configure applies the provided options sequentially from left to right func Configure(options ...Option) { for _, f := range options { f() } } -// LdJSONFormatter formats the event log as line-delimited JSON +// LdJSONFormatter Option formats the event log as line-delimited JSON var LdJSONFormatter = func() { logrus.SetFormatter(&PoliteJSONFormatter{}) } +// TextFormatter Option formats the event log as human-readable plain-text var TextFormatter = func() { logrus.SetFormatter(&logrus.TextFormatter{}) } @@ -60,14 +62,17 @@ func OutputRotatingLogFile(config LogRotatorConfig) Option { } } +// LevelDebug Option sets the log level to debug var LevelDebug = func() { logrus.SetLevel(logrus.DebugLevel) } +// LevelDebug Option sets the log level to error var LevelError = func() { logrus.SetLevel(logrus.ErrorLevel) } +// LevelDebug Option sets the log level to info var LevelInfo = func() { logrus.SetLevel(logrus.InfoLevel) }