docs(eventlog)

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
Brian Tiger Chow 2014-11-22 20:49:02 -08:00
parent 58d299eb2e
commit 247fd676a3
2 changed files with 9 additions and 1 deletions

View File

@ -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 {

View File

@ -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)
}