Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoColorUnderJSONFormat = fmt.Errorf("no_color is only valid when log format is 'console'")
ErrNoColorUnderJSONFormat is returned by Validate when NoColor is enabled while LogFormat is "json"; the option only applies to the console writer.
Functions ¶
func NewLogger ¶
NewLogger creates a new logger writing to out. The logger will emit a timestamp, the caller's filename, and optionally emit the stacktrace for errors that carry a stack trace.
The Debug and Trace level are samples. It allows up to 100 trace logs per minutes. Additional trace logs will be filtered out. Debug logs are sampled. Every 5th log will be filtered out once the limit of 1000 debug logs per minute is reached.
func SetGlobalLogger ¶
SetGlobalLogger sets the log output in the stdlib log package and the zerolog global loggers.
Types ¶
type Config ¶
type Config struct {
// LogLevel selects the minimum log level emitted. Supported values are
// trace, debug, info, warn, error, fatal, panic, and disabled. An empty
// string disables level filtering (every event is written).
LogLevel string
// LogFormat selects the output encoding. Supported values are "console"
// (human-readable) and "json" (structured, one JSON object per line).
// An empty string defaults to "console". Unknown values also fall back
// to "console"; CLI input is validated up front by Config.Validate.
LogFormat string
// NoColor disables ANSI colors in the "console" format. Ignored when
// LogFormat is "json".
NoColor bool
}
Click to show internal directories.
Click to hide internal directories.