package logrusimport// Default key names for the default fieldsconst (defaultTimestampFormat = time.RFC3339FieldKeyMsg = "msg"FieldKeyLevel = "level"FieldKeyTime = "time"FieldKeyLogrusError = "logrus_error"FieldKeyFunc = "func"FieldKeyFile = "file")// The Formatter interface is used to implement a custom Formatter. It takes an// `Entry`. It exposes all the fields, including the default ones://// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..// * `entry.Data["time"]`. The timestamp.// * `entry.Data["level"]. The level the entry was logged at.//// Any additional fields added with `WithField` or `WithFields` are also in// `entry.Data`. Format is expected to return an array of bytes which are then// logged to `logger.Out`.typeFormatterinterface {Format(*Entry) ([]byte, error)}// This is to not silently overwrite `time`, `msg`, `func` and `level` fields when// dumping it. If this code wasn't there doing://// logrus.WithField("level", 1).Info("hello")//// Would just silently drop the user provided level. Instead with this code// it'll logged as://// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}//// It's not exported because it's still using Data in an opinionated way. It's to// avoid code duplication between the two default formatters.func ( Fields, FieldMap, bool) { := .resolve(FieldKeyTime)if , := []; { ["fields."+] = delete(, ) } := .resolve(FieldKeyMsg)if , := []; { ["fields."+] = delete(, ) } := .resolve(FieldKeyLevel)if , := []; { ["fields."+] = delete(, ) } := .resolve(FieldKeyLogrusError)if , := []; { ["fields."+] = delete(, ) }// If reportCaller is not set, 'func' will not conflict.if { := .resolve(FieldKeyFunc)if , := []; { ["fields."+] = } := .resolve(FieldKeyFile)if , := []; { ["fields."+] = } }}
The pages are generated with Goldsv0.3.6. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.