Documentation ¶
Index ¶
- Constants
- func SetGlobalLogger(l *Logger)
- type Level
- type Logger
- func (l *Logger) Debug(msg string, fields ...interface{})
- func (l *Logger) Error(err error, msg string, fields ...interface{})
- func (l *Logger) Fatal(err error, msg string, fields ...interface{})
- func (l *Logger) Flush() error
- func (l *Logger) Info(msg string, fields ...interface{})
- func (l *Logger) SetAsGlobal()
- func (l *Logger) SetLevel(lvl Level) *Logger
- func (l *Logger) SetLevelFromString(lvlStr string) *Logger
- func (l *Logger) Warn(msg string, fields ...interface{})
- func (l *Logger) With(fields ...interface{}) *Logger
- func (l *Logger) WithComponent(id string) *Logger
- func (l *Logger) WithError(err error) *Logger
Constants ¶
const ( // ErrorKey is used to associate an error with the a message ErrorKey = "error" // ComponentKey is used to associate a component or class with a log message ComponentKey = "component" // CallstackKey is used to associate a callstack with a log message CallstackKey = "callstack" // HostnameKey is used to associate a hostname with a log message HostnameKey = "hostname" // LevelKey is used to associate a level with a log message LevelKey = "level" // LocationKey is used to associate a location with a log message LocationKey = "location" // MessageKey is used to associate a message with a log message MessageKey = "message" // ServiceKey is used to associate a service with a log message ServiceKey = "service" // TimeKey is used to associate a time with a log message TimeKey = "time" // QueueID is used to associate a queue identifier with a log message QueueID = "queueID" // Topic is used to associate a topic name with a log message Topic = "topic" // Partition is used to associate a partition id with a log message Partition = "partition" // Offset is used to associate a Kafka message offset with a log message Offset = "offset" )
const ( DebugLevel = Level(zapcore.DebugLevel) InfoLevel = Level(zapcore.InfoLevel) WarnLevel = Level(zapcore.WarnLevel) ErrorLevel = Level(zapcore.ErrorLevel) FatalLevel = Level(zapcore.FatalLevel) )
Logging level constants.
Variables ¶
This section is empty.
Functions ¶
func SetGlobalLogger ¶
func SetGlobalLogger(l *Logger)
SetGlobalLogger sets the global logger. By default it is a no-op logger. Passing nil will panic.
Types ¶
type Level ¶
Level indicates the importance of a log line. Higher levels are more important.
func ParseLevel ¶
ParseLevel converts a level string into a Level value. returns an error if the input string does not match known values.
func (*Level) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. It marshals the level into its string representation and returns it as a byte array. Text strings are one of the following: "debug", "info", "warn", "error", "fatal"
func (Level) String ¶
String implements the fmt.Stringer interface. It converts log severity level to string
func (*Level) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. It unmarshals a byte array representing a log string into a log level object and assigns it to the level. Text strings must be one of the following: "debug", "info", "warn", "error", "fatal"
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a logger implementation that wraps go-observation/logging
func Global ¶
func Global() *Logger
Global returns the global logger. The default logger is a no-op logger.
func New ¶
New constructs a new logger using the default stdout for output. The serviceName argument will be traced as the standard "service" field on every trace.
func NewNoOp ¶
func NewNoOp() *Logger
NewNoOp returns a no-op Logger that doesn't emit any logs. This is the default global logger.
func NewWithOutput ¶
NewWithOutput constructs a new logger and writes output to writer. writer is an io.writer that also supports concurrent writes. The writer will be wrapped with zapcore.AddSync()
func With ¶
func With(fields ...interface{}) *Logger
With includes the specified fields with each log message sent by this logger
func WithComponent ¶
WithComponent includes the specified component id as a field with each log message sent by this logger
func (*Logger) Fatal ¶
Fatal logs a message at FatalLevel and then calls os.Exit(1). err is traced as {"error": err.Error()}
func (*Logger) Flush ¶
Flush ensures that all buffered messages are written. Normally it only needs to be called before program exit.
func (*Logger) SetAsGlobal ¶
func (l *Logger) SetAsGlobal()
SetAsGlobal sets this logger as the global logger
func (*Logger) SetLevelFromString ¶
SetLevelFromString sets the log level for this logger
func (*Logger) WithComponent ¶
WithComponent includes the specified component id as a field with each log message sent by this logger