{"modulePath":"github.com/DoNewsCode/core","version":"v0.12.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package logging\n\nPackage logging provides a kitlog compatible logger.\n\nThis package is mostly a thin wrapper around kitlog ([http://github.com/go-kit/log](http://github.com/go-kit/log)). kitlog provides a minimalist, contextual, fully composable logger. However, it is too unopinionated, hence requiring some efforts and coordination to set up a good practise.\n\n### Integration {#hdr-Integration}\n\nPackage logging is bundled in core. Enable logging as dependency by calling:\n\n\tvar c *core.C = core.New()\n\tc.ProvideEssentials()\n\nSee example for usage.\n\n## Functions\n\n```go\nfunc LevelFilter(levelCfg string) level.Option\n```\nLevelFilter filters the log output based on its level. Allowed levels are \"debug\", \"info\", \"warn\", \"error\", or \"none\"\n\n```go\nfunc NewLogger(format string) (logger log.Logger)\n```\nNewLogger constructs a log.Logger based on the given format. The support formats are \"json\" and \"logfmt\".\n\n```go\nfunc Sprint(args ...interface{}) fmt.Stringer\n```\nSprint returns a log entry that is formatted using fmt.Sprint just before writing to the output. This is more desirable than using fmt.Sprint from the caller's end because the cost of formatting can be avoided if the log is filtered, for example, by log level.\n\n```go\nfunc Sprintf(format string, args ...interface{}) fmt.Stringer\n```\nSprintf returns a log entry that is formatted using fmt.Sprintf just before writing to the output. This is more desirable than using fmt.Sprintf from the caller's end because the cost of formatting can be avoided if the log is filtered, for example, by log level.\n\n```go\nfunc WithBaggage(logger log.Logger, ctx context.Context) log.Logger\n```\nWithBaggage decorates the log.Logger with information form context.\n\n```go\nfunc WithContext(logger log.Logger, ctx context.Context) log.Logger\n```\nWithContext decorates the log.Logger with information form context. If there is an opentracing span in the context, the span will receive the logger output as well.\n\n## Types\n\n```go\ntype LevelLogger = contract.LevelLogger\n```\nLevelLogger is an alias of contract.LevelLogger\n\n```go\nfunc WithLevel(logger log.Logger) LevelLogger\n```\nWithLevel decorates the logger and returns a contract.LevelLogger.\n\nNote: Don't inject contract.LevelLogger to dependency consumers directly as this will weaken the powerful abstraction of log.Logger. Only inject log.Logger, and converts log.Logger to contract.LevelLogger within the boundary of dependency consumer if desired.\n\n","path":"github.com/DoNewsCode/core/logging","name":"logging","synopsis":"Package logging provides a kitlog compatible logger.","isRedistributable":true}
