mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-23 11:27:42 +08:00
docs(eventlog)
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
parent
58d299eb2e
commit
247fd676a3
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user