提交 247fd676 作者: Brian Tiger Chow

docs(eventlog)

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 58d299eb
......@@ -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 {
......
......@@ -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)
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论