Documentation ¶
Index ¶
- Constants
- func WriteAt(l Structured, lvl Level, msg string, fields ...Field) error
- type Field
- func Any(key string, value interface{}) Field
- func Array(key string, value interface{}) Field
- func Binary(key string, value []byte) Field
- func Bool(key string, value bool) Field
- func Bools(key string, value []bool) Field
- func ByteString(key string, value []byte) Field
- func Context(ctx context.Context) Field
- func Duration(key string, value time.Duration) Field
- func Durations(key string, value []time.Duration) Field
- func Error(value error) Field
- func Errors(key string, value []error) Field
- func Float32(key string, value float32) Field
- func Float32s(key string, value []float32) Field
- func Float64(key string, value float64) Field
- func Float64s(key string, value []float64) Field
- func Int(key string, value int) Field
- func Int16(key string, value int16) Field
- func Int16s(key string, value []int16) Field
- func Int32(key string, value int32) Field
- func Int32s(key string, value []int32) Field
- func Int64(key string, value int64) Field
- func Int64s(key string, value []int64) Field
- func Int8(key string, value int8) Field
- func Int8s(key string, value []int8) Field
- func Ints(key string, value []int) Field
- func NamedError(key string, value error) Field
- func Nil(key string) Field
- func Reflect(key string, value interface{}) Field
- func Sprintf(key, format string, args ...interface{}) Field
- func String(key, value string) Field
- func Strings(key string, value []string) Field
- func Time(key string, value time.Time) Field
- func Times(key string, value []time.Time) Field
- func UInt(key string, value uint) Field
- func UInt16(key string, value uint16) Field
- func UInt16s(key string, value []uint16) Field
- func UInt32(key string, value uint32) Field
- func UInt32s(key string, value []uint32) Field
- func UInt64(key string, value uint64) Field
- func UInt64s(key string, value []uint64) Field
- func UInt8(key string, value uint8) Field
- func UInt8s(key string, value []uint8) Field
- func UInts(key string, value []uint) Field
- func (f Field) Any() interface{}
- func (f Field) Binary() []byte
- func (f Field) Bool() bool
- func (f Field) Duration() time.Duration
- func (f Field) Error() error
- func (f Field) Float() float64
- func (f Field) Interface() interface{}
- func (f Field) Key() string
- func (f Field) Signed() int64
- func (f Field) String() string
- func (f Field) Time() time.Time
- func (f Field) Type() FieldType
- func (f Field) Unsigned() uint64
- type FieldType
- type Fmt
- type Level
- type Logger
- type LoggerAddCallerSkip
- type LoggerWith
- type Structured
Constants ¶
const ( TraceString = "trace" DebugString = "debug" InfoString = "info" WarnString = "warn" ErrorString = "error" FatalString = "fatal" )
String values for standard log levels
const (
// DefaultErrorFieldName is the default field name used for errors
DefaultErrorFieldName = "error"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field stores one structured logging field
func Any ¶
Any tries to deduce interface{} underlying type and constructs Field from it. Use of this function is ok only for the sole purpose of not repeating its entire code or parts of it in user's code (when you need to log interface{} types with unknown content). Otherwise please use specialized functions. nolint: gocyclo
func ByteString ¶
ByteString constructs field of bytes that could represent UTF-8 string
func NamedError ¶
NamedError constructs field of error type
func (Field) Any ¶
func (f Field) Any() interface{}
Any returns contained data as interface{} nolint: gocyclo
type FieldType ¶
type FieldType int
FieldType is a type of data Field can represent
const ( // FieldTypeNil is for a pure nil FieldTypeNil FieldType = iota // FieldTypeString is for a string FieldTypeString // FieldTypeBinary is for a binary array FieldTypeBinary // FieldTypeBoolean is for boolean FieldTypeBoolean // FieldTypeSigned is for signed integers FieldTypeSigned // FieldTypeUnsigned is for unsigned integers FieldTypeUnsigned // FieldTypeFloat is for float FieldTypeFloat // FieldTypeTime is for time.Time FieldTypeTime // FieldTypeDuration is for time.Duration FieldTypeDuration // FieldTypeError is for an error FieldTypeError // FieldTypeArray is for an array of any type FieldTypeArray // FieldTypeAny is for any type FieldTypeAny // FieldTypeReflect is for unknown types FieldTypeReflect // FieldTypeByteString is for a bytes that can be represented as UTF-8 string FieldTypeByteString // FieldTypeContext wraps context for lazy context fields evaluation if possible FieldTypeContext )
type Fmt ¶
type Fmt interface {
// contains filtered or unexported methods
}
Fmt provides interface for logging using fmt formatter.
type Level ¶
type Level int
Level of logging
Standard log levels
func ParseLevel ¶
ParseLevel parses log level from string. Returns ErrUnknownLevel for unknown log level.
func (Level) MarshalText ¶
MarshalText marshals level to text
func (*Level) UnmarshalText ¶
UnmarshalText unmarshals level from text
type Logger ¶
type Logger interface {
// contains filtered or unexported methods
}
Logger is the universal logger that can do everything.
func AddCallerSkip ¶
AddCallerSkip for loggers that implement LoggerAddCallerSkip interface, returns logger that adds caller skip to each log entry. Otherwise returns same logger.
type LoggerAddCallerSkip ¶
type LoggerAddCallerSkip interface { // AddCallerSkip implements 'AddCallerSkip' AddCallerSkip(skip int) Logger }
LoggerAddCallerSkip is an interface for 'AddCallerSkip' function
type LoggerWith ¶
LoggerWith is an interface for 'With' function LoggerWith provides interface for logger modifications.
type Structured ¶
type Structured interface {
// contains filtered or unexported methods
}
Structured provides interface for logging using fields.