docs(eventlog)
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Nov 22, 2014 at 20:49 UTC
247fd676a36da657e7f4941830544dfd3ce55592
2 files changed
+9
-1
util/eventlog/context.go
+3
@@ -10,6 +10,9 @@ type key int
10
11
const metadataKey key = 0
12
13
+// ContextWithLoggable returns a derived context which contains the provided
14
+// Loggable. Any Events logged with the derived context will include the
15
+// provided Loggable.
16
func ContextWithLoggable(ctx context.Context, l Loggable) context.Context {
17
existing, err := MetadataFromContext(ctx)
18
if err != nil {
util/eventlog/option.go
+6
-1
@@ -19,17 +19,19 @@ func init() {
19
20
type Option func()
21
22
+// Configure applies the provided options sequentially from left to right
23
func Configure(options ...Option) {
24
for _, f := range options {
25
f()
26
}
27
}
28
28
-// LdJSONFormatter formats the event log as line-delimited JSON
29
+// LdJSONFormatter Option formats the event log as line-delimited JSON
30
var LdJSONFormatter = func() {
31
logrus.SetFormatter(&PoliteJSONFormatter{})
32
}
33
34
+// TextFormatter Option formats the event log as human-readable plain-text
35
var TextFormatter = func() {
36
logrus.SetFormatter(&logrus.TextFormatter{})
37
}
@@ -60,14 +62,17 @@ func OutputRotatingLogFile(config LogRotatorConfig) Option {
62
}
63
}
64
65
+// LevelDebug Option sets the log level to debug
66
var LevelDebug = func() {
67
logrus.SetLevel(logrus.DebugLevel)
68
}
69
70
+// LevelDebug Option sets the log level to error
71
var LevelError = func() {
72
logrus.SetLevel(logrus.ErrorLevel)
73
}
74
75
+// LevelDebug Option sets the log level to info
76
var LevelInfo = func() {
77
logrus.SetLevel(logrus.InfoLevel)
78
}