Documentation
¶
Index ¶
Constants ¶
const FieldReplay = "replayed-from-level"
FieldReplay is a field assigned to a message that has been replayed at a different log level. Its value is equal to the original log level.
const FieldRollup = "rollup-multiplicity"
FieldRollup is a field assigned to the last message in a window. Its value is equal to the number of messages in the window before it was flushed.
const JSONTimeFormat = "2006-01-02T15:04:05.000-0700"
Variables ¶
var ( ErrIllegalLevel = fmt.Errorf("illegal log level") ErrIllegalEncoding = fmt.Errorf("illegal log encoding") )
Functions ¶
func LogEmergencyError ¶
func LogEmergencyErrors ¶
Types ¶
type Config ¶
type Config struct {
LogLevel string `env:"log_level" file:"log_level" default:"info"`
LogEncoding string `env:"log_encoding" file:"log_encoding" default:"console"`
LogColorize bool `env:"log_colorize" file:"log_colorize" default:"true"`
LogJSONFieldNames map[string]string `env:"log_json_field_names" file:"log_json_field_names"`
LogInitialFields LogFields `env:"log_fields" file:"log_fields"`
LogShortTime bool `env:"log_short_time" file:"log_short_time" default:"false"`
LogDisplayFields bool `env:"log_display_fields" file:"log_display_fields" default:"true"`
LogDisplayMultilineFields bool `env:"log_display_multiline_fields" file:"log_display_multiline_fields" default:"false"`
LogFieldBlacklist []string `env:"log_field_blacklist" file:"log_field_blacklist"`
}
type Logger ¶
type Logger interface {
WithIndirectCaller(frames int) Logger
WithFields(LogFields) Logger
LogWithFields(LogLevel, LogFields, string, ...interface{})
Sync() error
// Convenience Methods
Debug(string, ...interface{})
Info(string, ...interface{})
Warning(string, ...interface{})
Error(string, ...interface{})
Fatal(string, ...interface{})
DebugWithFields(LogFields, string, ...interface{})
InfoWithFields(LogFields, string, ...interface{})
WarningWithFields(LogFields, string, ...interface{})
ErrorWithFields(LogFields, string, ...interface{})
FatalWithFields(LogFields, string, ...interface{})
}
func EmergencyLogger ¶
func EmergencyLogger() Logger
func InitLogger ¶ added in v1.1.0
func NewNilLogger ¶
func NewNilLogger() Logger
func NewRollupAdapter ¶
NewRollupAdapter returns a logger with functionality to throttle similar messages. Messages begin a roll-up when a second messages with an identical format string is seen in the same window period. All remaining messages logged within that period are captured and emitted as a single message at the end of the window period. The fields and args are equal to the first rolled-up message.
type ReplayLogger ¶
type ReplayLogger interface {
Logger
// Replay will cause all of the messages previously logged at one of the
// journaled levels to be re-set at the given level. All future messages
// logged at one of the journaled levels will be replayed immediately.
Replay(LogLevel)
}
ReplayLogger is a Logger that provides a way to replay a sequence of message in the order they were logged, at a higher log level.
func NewReplayAdapter ¶
func NewReplayAdapter(logger Logger, levels ...LogLevel) ReplayLogger
NewReplayAdapter creates a ReplayLogger wrapping the given logger.