Documentation ¶
Index ¶
- Variables
- func AddHook(h Hook) error
- func Debug(msg ...interface{})
- func Debugf(msg string, args ...interface{})
- func Error(msg ...interface{})
- func Errorf(msg string, args ...interface{})
- func Fatal(msg ...interface{})
- func Fatalf(msg string, args ...interface{})
- func Info(msg ...interface{})
- func Infof(msg string, args ...interface{})
- func IsLevelEnabled(level Level) bool
- func Panic(msg ...interface{})
- func Panicf(msg string, args ...interface{})
- func Print(msg ...interface{})
- func Printf(msg string, args ...interface{})
- func ReleaseBuffer(b *Buffer)
- func SetEncoder(enc Encoder)
- func SetFields(fields ...Field)
- func SetFlags(flag Flag)
- func SetLevel(level Level)
- func SetOutput(output io.Writer)
- func Trace(msg ...interface{})
- func Tracef(msg string, args ...interface{})
- func Warning(msg ...interface{})
- func Warningf(msg string, args ...interface{})
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Escape(startAt int)
- func (b *Buffer) Len() int
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Write(s []byte) (int, error)
- func (b *Buffer) WriteByte(s byte) error
- func (b *Buffer) WriteDatetime(now time.Time, layout string)
- func (b *Buffer) WriteFileCaller(f runtime.Frame, short bool)
- func (b *Buffer) WriteInterface(value interface{})
- func (b *Buffer) WriteNewLine()
- func (b *Buffer) WriteString(s string) (int, error)
- func (b *Buffer) WriteTimestamp(now time.Time, format TimestampFormat)
- func (b *Buffer) WriteTo(w io.Writer) (int64, error)
- type Config
- type Encoder
- type EncoderBase
- type EncoderJSON
- type EncoderJSONConfig
- type EncoderText
- type EncoderTextConfig
- type EnconderJSONFieldMap
- type Entry
- type Field
- type Flag
- type Hook
- type Level
- type Logger
- func (l *Logger) AddHook(h Hook) error
- func (l *Logger) Debug(msg ...interface{})
- func (l *Logger) Debugf(msg string, args ...interface{})
- func (l *Logger) Error(msg ...interface{})
- func (l *Logger) Errorf(msg string, args ...interface{})
- func (l *Logger) Fatal(msg ...interface{})
- func (l *Logger) Fatalf(msg string, args ...interface{})
- func (l *Logger) Info(msg ...interface{})
- func (l *Logger) Infof(msg string, args ...interface{})
- func (l *Logger) IsLevelEnabled(level Level) bool
- func (l *Logger) Panic(msg ...interface{})
- func (l *Logger) Panicf(msg string, args ...interface{})
- func (l *Logger) Print(msg ...interface{})
- func (l *Logger) Printf(msg string, args ...interface{})
- func (l *Logger) SetEncoder(enc Encoder)
- func (l *Logger) SetFields(fields ...Field)
- func (l *Logger) SetFlags(flag Flag)
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetOutput(output io.Writer)
- func (l *Logger) Trace(msg ...interface{})
- func (l *Logger) Tracef(msg string, args ...interface{})
- func (l *Logger) Warning(msg ...interface{})
- func (l *Logger) Warningf(msg string, args ...interface{})
- func (l *Logger) WithFields(fields ...Field) *Logger
- type TimestampFormat
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidLevel is the invalid level error. ErrInvalidLevel = errors.New("invalid level") // ErrEmptyHookLevels is the empty hook levels error. ErrEmptyHookLevels = errors.New("empty hook levels") )
Functions ¶
func IsLevelEnabled ¶
IsLevelEnabled checks if the given level is enabled on the standard logger.
func ReleaseBuffer ¶
func ReleaseBuffer(b *Buffer)
ReleaseBuffer puts the given buffer in the pool after it is reset.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer provides the byte buffer used by encoders to encode the output.
func AcquireBuffer ¶
func AcquireBuffer() *Buffer
AcquireBuffer returns a buffer instance from pool.
func (*Buffer) WriteDatetime ¶
WriteDatetime writes the given time to the buffer formatted with the given layout.
func (*Buffer) WriteFileCaller ¶
WriteFileCaller writes the file caller to the buffer.
func (*Buffer) WriteInterface ¶
func (b *Buffer) WriteInterface(value interface{})
WriteInterface writes an interface value to the buffer.
func (*Buffer) WriteNewLine ¶
func (b *Buffer) WriteNewLine()
WriteNewLine writes a new line to the buffer if it's needed.
func (*Buffer) WriteString ¶
WriteString writes the given string to the buffer.
func (*Buffer) WriteTimestamp ¶
func (b *Buffer) WriteTimestamp(now time.Time, format TimestampFormat)
WriteTimestamp writes the timestamp to the buffer from the given time.
type Config ¶
type Config struct { Fields []Field Datetime bool Timestamp bool UTC bool Shortfile bool Longfile bool Function bool // contains filtered or unexported fields }
Config is the logger configuration.
type Encoder ¶
type Encoder interface { Copy() Encoder FieldsEncoded() string SetFieldsEncoded(fieldsEncoded string) Configure(cfg Config) Encode(b *Buffer, e Entry) error }
Encoder represents the encoders contract.
type EncoderBase ¶
type EncoderBase struct {
// contains filtered or unexported fields
}
EncoderBase is the base of encoders.
func (*EncoderBase) Copy ¶
func (enc *EncoderBase) Copy() *EncoderBase
Copy returns a copy of the encoder base.
func (*EncoderBase) FieldsEncoded ¶
func (enc *EncoderBase) FieldsEncoded() string
FieldsEncoded returns the encoded fields.
func (*EncoderBase) SetFieldsEncoded ¶
func (enc *EncoderBase) SetFieldsEncoded(fieldsEncoded string)
SetFieldsEncoded sets the fields enconded.
type EncoderJSON ¶
type EncoderJSON struct { EncoderBase // contains filtered or unexported fields }
EncoderJSON is the json encoder.
func NewEncoderJSON ¶
func NewEncoderJSON(cfg EncoderJSONConfig) *EncoderJSON
NewEncoderJSON creates a new json encoder.
func (*EncoderJSON) Configure ¶
func (enc *EncoderJSON) Configure(cfg Config)
Configure configures then encoder.
- Encondes and sets the fields.
func (*EncoderJSON) Copy ¶
func (enc *EncoderJSON) Copy() Encoder
Copy returns a copy of the json encoder.
type EncoderJSONConfig ¶
type EncoderJSONConfig struct { FieldMap EnconderJSONFieldMap // Default: time.RFC3339 DatetimeLayout string // Default: TimestampFormatSeconds TimestampFormat TimestampFormat }
EncoderJSONConfig is the configuration of json encoder.
type EncoderText ¶
type EncoderText struct { EncoderBase // contains filtered or unexported fields }
EncoderText is the text enconder.
func NewEncoderText ¶
func NewEncoderText(cfg EncoderTextConfig) *EncoderText
NewEncoderText creates a new text encoder.
func (*EncoderText) Configure ¶
func (enc *EncoderText) Configure(cfg Config)
Configure configures then encoder.
- Encondes and sets the fields.
func (*EncoderText) Copy ¶
func (enc *EncoderText) Copy() Encoder
Copy returns a copy of the text encoder.
type EncoderTextConfig ¶
type EncoderTextConfig struct { // Default: - Separator string // Default: time.RFC3339 DatetimeLayout string // Default: TimestampFormatSeconds TimestampFormat TimestampFormat }
EncoderTextConfig is the configuration of text encoder.
type EnconderJSONFieldMap ¶
type EnconderJSONFieldMap struct { // Default: datetime DatetimeKey string // Default: timestamp TimestampKey string // Default: level LevelKey string // Default: file FileKey string // Default: func FunctionKey string // Default: message MessageKey string }
EnconderJSONFieldMap defines name of keys.
type Entry ¶
type Entry struct { Config Config Time time.Time Level Level Caller runtime.Frame Message string RawMessage string Args []interface{} }
Entry collects all the information for the output.
type Hook ¶
type Hook interface { // Levels returns the levels at which the hook fires. Levels() []Level // Fire is hook function. // // NOTE: The returned error will be written to `os.Stderr`. Fire(e Entry) error }
Hook represents a extended functionality that will be fired when logging.
NOTE: This is not run concurrently, so be quite with locks.
type Level ¶
type Level int
Level type.
const ( PRINT Level PANIC FATAL ERROR WARNING INFO DEBUG TRACE )
Logger levels.
func ParseLevel ¶
ParseLevel returns the Level constant from the given level string.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger type.
func WithFields ¶
WithFields returns a copy of the standard logger with the given fields.
func (*Logger) IsLevelEnabled ¶
IsLevelEnabled checks if the given level is enabled on the logger.
func (*Logger) SetEncoder ¶
SetEncoder sets the logger encoder.
func (*Logger) WithFields ¶
WithFields returns a logger copy with the given fields.
type TimestampFormat ¶
type TimestampFormat int
TimestampFormat type.
const ( TimestampFormatSeconds TimestampFormat = iota + 1 TimestampFormatNanoseconds )
Logger timestamp formats.