Documentation ¶
Index ¶
- func SetLevel(level Level)
- type Config
- type Field
- func Bool(name string, value bool) Field
- func Boolp(name string, value *bool) Field
- func Bools(name string, value []bool) Field
- func Byte(name string, value byte) Field
- func ByteString(name string, value []byte) Field
- func ByteStrings(name string, value [][]byte) Field
- func Bytes(name string, value []byte) Field
- func Complex128(name string, value complex128) Field
- func Complex128p(name string, value *complex128) Field
- func Complex128s(name string, value []complex128) Field
- func Complex64(name string, value complex64) Field
- func Complex64p(name string, value *complex64) Field
- func Complex64s(name string, value []complex64) Field
- func Duration(name string, value time.Duration) Field
- func Durationp(name string, value *time.Duration) Field
- func Durations(name string, value []time.Duration) Field
- func Error(name string, err error) Field
- func Float32(name string, value float32) Field
- func Float32p(name string, value *float32) Field
- func Float32s(name string, value []float32) Field
- func Float64(name string, value float64) Field
- func Float64p(name string, value *float64) Field
- func Float64s(name string, value []float64) Field
- func Int(name string, value int) Field
- func Int32(name string, value int32) Field
- func Int32p(name string, value *int32) Field
- func Int32s(name string, value []int32) Field
- func Int64(name string, value int64) Field
- func Int64p(name string, value *int64) Field
- func Int64s(name string, value []int64) Field
- func Intp(name string, value *int) Field
- func Ints(name string, value []int) Field
- func String(name string, value string) Field
- func Stringer(name string, value fmt.Stringer) Field
- func Stringp(name string, value *string) Field
- func Strings(name string, value []string) Field
- func Time(name string, value time.Time) Field
- func Timep(name string, value *time.Time) Field
- func Times(name string, value []time.Time) Field
- func Uint(name string, value uint) Field
- func Uint32(name string, value uint32) Field
- func Uint32p(name string, value *uint32) Field
- func Uint32s(name string, value []uint32) Field
- func Uint64(name string, value uint64) Field
- func Uint64p(name string, value *uint64) Field
- func Uint64s(name string, value []uint64) Field
- func Uintp(name string, value *uint) Field
- func Uints(name string, value []uint) Field
- type FileSinkConfig
- type KafkaSinkConfig
- type Level
- type Logger
- type LoggerConfig
- type Output
- type OutputConfig
- type SinkConfig
- func (c SinkConfig) GetEncoding() SinkEncoding
- func (c SinkConfig) GetFileSinkConfig() FileSinkConfig
- func (c SinkConfig) GetKafkaSinkConfig() KafkaSinkConfig
- func (c SinkConfig) GetStderrSinkConfig() StderrSinkConfig
- func (c SinkConfig) GetStdoutSinkConfig() StdoutSinkConfig
- func (c SinkConfig) GetType() SinkType
- type SinkEncoding
- type SinkType
- type StderrSinkConfig
- type StdoutSinkConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Loggers map[string]LoggerConfig `yaml:"loggers"` Sinks map[string]SinkConfig `yaml:"sinks"` }
Config logging configuration
func (Config) GetLogger ¶
func (c Config) GetLogger(name string) (LoggerConfig, bool)
GetLogger returns a logger by name
func (Config) GetLoggers ¶
func (c Config) GetLoggers() []LoggerConfig
GetLoggers returns the configured loggers
func (Config) GetRootLogger ¶
func (c Config) GetRootLogger() LoggerConfig
GetRootLogger returns the root logger configuration
func (Config) GetSink ¶
func (c Config) GetSink(name string) (SinkConfig, bool)
GetSink returns a sink by name
func (Config) GetSinks ¶
func (c Config) GetSinks() []SinkConfig
GetSinks returns the configured sinks
type Field ¶
type Field interface {
// contains filtered or unexported methods
}
Field is a structured logger field
func ByteString ¶
ByteString creates a named byte string field
func ByteStrings ¶
ByteStrings creates a named byte string slice field
func Complex128 ¶
func Complex128(name string, value complex128) Field
Complex128 creates a named complex128 field
func Complex128p ¶
func Complex128p(name string, value *complex128) Field
Complex128p creates a named complex128 pointer field
func Complex128s ¶
func Complex128s(name string, value []complex128) Field
Complex128s creates a named complex128 slice field
func Complex64p ¶
Complex64p creates a named complex64 pointer field
func Complex64s ¶
Complex64s creates a named complex64 slice field
type FileSinkConfig ¶
type FileSinkConfig struct {
Path string `yaml:"path"`
}
FileSinkConfig is the configuration for a file sink
type KafkaSinkConfig ¶
type KafkaSinkConfig struct { Topic string `yaml:"topic"` Key string `yaml:"key"` Brokers []string `yaml:"brokers"` }
KafkaSinkConfig is the configuration for a Kafka sink
type Level ¶
type Level int32
Level :
const ( // DebugLevel logs a message at debug level DebugLevel Level = iota // InfoLevel logs a message at info level InfoLevel // WarnLevel logs a message at warning level WarnLevel // ErrorLevel logs a message at error level ErrorLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel // PanicLevel logs a message, then panics. PanicLevel // DPanicLevel logs at PanicLevel; otherwise, it logs at ErrorLevel DPanicLevel // EmptyLevel : EmptyLevel )
type Logger ¶
type Logger interface { // Name returns the logger name Name() string // GetLogger gets a descendant of this Logger GetLogger(names ...string) Logger // Level returns the logger's level Level() Level // SetLevel sets the logger's level SetLevel(level Level) // WithFields adds fields to the logger WithFields(fields ...Field) Logger // Sync flushes the logger Sync() error Debug(...interface{}) Debugf(template string, args ...interface{}) Debugw(msg string, fields ...Field) Info(...interface{}) Infof(template string, args ...interface{}) Infow(msg string, fields ...Field) Error(...interface{}) Errorf(template string, args ...interface{}) Errorw(msg string, fields ...Field) Fatal(...interface{}) Fatalf(template string, args ...interface{}) Fatalw(msg string, fields ...Field) Panic(...interface{}) Panicf(template string, args ...interface{}) Panicw(msg string, fields ...Field) DPanic(...interface{}) DPanicf(template string, args ...interface{}) DPanicw(msg string, fields ...Field) Warn(...interface{}) Warnf(template string, args ...interface{}) Warnw(msg string, fields ...Field) }
Logger represents an abstract logging interface.
type LoggerConfig ¶
type LoggerConfig struct { Name string `yaml:"name"` Level *string `yaml:"level,omitempty"` Output map[string]OutputConfig `yaml:"output"` }
LoggerConfig is the configuration for a logger
func (LoggerConfig) GetLevel ¶
func (c LoggerConfig) GetLevel() Level
GetLevel returns the logger level
func (LoggerConfig) GetOutput ¶
func (c LoggerConfig) GetOutput(name string) (OutputConfig, bool)
GetOutput returns an output by name
func (LoggerConfig) GetOutputs ¶
func (c LoggerConfig) GetOutputs() []OutputConfig
GetOutputs returns the logger outputs
type Output ¶
type Output interface { WithFields(fields ...Field) Output Debug(msg string, fields ...Field) Info(msg string, fields ...Field) Error(msg string, fields ...Field) Fatal(msg string, fields ...Field) Panic(msg string, fields ...Field) DPanic(msg string, fields ...Field) Warn(msg string, fields ...Field) Sync() error }
Output is a logging output
type OutputConfig ¶
type OutputConfig struct { Name string `yaml:"name"` Sink *string `yaml:"sink"` Level *string `yaml:"level,omitempty"` }
OutputConfig is the configuration for a sink output
func (OutputConfig) GetLevel ¶
func (c OutputConfig) GetLevel() Level
GetLevel returns the output level
func (OutputConfig) GetSink ¶
func (c OutputConfig) GetSink() string
GetSink returns the output sink
type SinkConfig ¶
type SinkConfig struct { Name string `yaml:"name"` Type *SinkType `yaml:"type,omitempty"` Encoding *SinkEncoding `yaml:"encoding,omitempty"` Stdout *StdoutSinkConfig `yaml:"stdout,omitempty"` Stderr *StderrSinkConfig `yaml:"stderr,omitempty"` File *FileSinkConfig `yaml:"file,omitempty"` Kafka *KafkaSinkConfig `yaml:"kafka,omitempty"` }
SinkConfig is the configuration for a sink
func (SinkConfig) GetEncoding ¶
func (c SinkConfig) GetEncoding() SinkEncoding
GetEncoding returns the sink encoding
func (SinkConfig) GetFileSinkConfig ¶
func (c SinkConfig) GetFileSinkConfig() FileSinkConfig
GetFileSinkConfig returns the file sink configuration
func (SinkConfig) GetKafkaSinkConfig ¶
func (c SinkConfig) GetKafkaSinkConfig() KafkaSinkConfig
GetKafkaSinkConfig returns the Kafka sink configuration
func (SinkConfig) GetStderrSinkConfig ¶
func (c SinkConfig) GetStderrSinkConfig() StderrSinkConfig
GetStderrSinkConfig returns the stderr sink configuration
func (SinkConfig) GetStdoutSinkConfig ¶
func (c SinkConfig) GetStdoutSinkConfig() StdoutSinkConfig
GetStdoutSinkConfig returns the stdout sink configuration
type SinkEncoding ¶
type SinkEncoding string
SinkEncoding is the encoding for a sink
const ( // ConsoleEncoding is an encoding for outputs to the console ConsoleEncoding SinkEncoding = "console" // JSONEncoding is an encoding for JSON outputs JSONEncoding SinkEncoding = "json" )
func (SinkEncoding) String ¶
func (e SinkEncoding) String() string
type SinkType ¶
type SinkType string
SinkType is the type of a sink
const ( // StdoutSinkType is the sink type for stdout StdoutSinkType SinkType = "stdout" // StderrSinkType is the sink type for stderr StderrSinkType SinkType = "stderr" // FileSinkType is the type for a file sink FileSinkType SinkType = "file" // KafkaSinkType is the sink type for the Kafka sink KafkaSinkType SinkType = "kafka" )
type StderrSinkConfig ¶
type StderrSinkConfig struct { }
StderrSinkConfig is the configuration for an stderr sink
type StdoutSinkConfig ¶
type StdoutSinkConfig struct { }
StdoutSinkConfig is the configuration for an stdout sink