Documentation
¶
Index ¶
- type Config
- type IAttributeLogger
- type ILogger
- type JSONMarshaller
- type JSONRecord
- type JsonLogRecord
- func (record *JsonLogRecord) Bool(name string, value bool) *JsonLogRecord
- func (record *JsonLogRecord) BoolArray(name string, value []bool) *JsonLogRecord
- func (record *JsonLogRecord) Byte(name string, value byte) *JsonLogRecord
- func (record *JsonLogRecord) ByteArray(name string, value []byte) *JsonLogRecord
- func (record *JsonLogRecord) Bytes(name string, value []byte) *JsonLogRecord
- func (record *JsonLogRecord) Debug(msg string, args ...any)
- func (record *JsonLogRecord) Error(msg string, args ...any)
- func (record *JsonLogRecord) Fatal(msg string, args ...any)
- func (record *JsonLogRecord) Float32(name string, value float32) *JsonLogRecord
- func (record *JsonLogRecord) Float32Array(name string, value []float32) *JsonLogRecord
- func (record *JsonLogRecord) Float64(name string, value float64) *JsonLogRecord
- func (record *JsonLogRecord) Float64Array(name string, value []float64) *JsonLogRecord
- func (record *JsonLogRecord) Info(msg string, args ...any)
- func (record *JsonLogRecord) Int(name string, value int) *JsonLogRecord
- func (record *JsonLogRecord) Int8(name string, value int8) *JsonLogRecord
- func (record *JsonLogRecord) Int8Array(name string, value []int8) *JsonLogRecord
- func (record *JsonLogRecord) Int16(name string, value int16) *JsonLogRecord
- func (record *JsonLogRecord) Int16Array(name string, value []int16) *JsonLogRecord
- func (record *JsonLogRecord) Int32(name string, value int32) *JsonLogRecord
- func (record *JsonLogRecord) Int32Array(name string, value []int32) *JsonLogRecord
- func (record *JsonLogRecord) Int64(name string, value int64) *JsonLogRecord
- func (record *JsonLogRecord) Int64Array(name string, value []int64) *JsonLogRecord
- func (record *JsonLogRecord) IntArray(name string, value []int) *JsonLogRecord
- func (record *JsonLogRecord) Log(msg string, args ...any)
- func (record *JsonLogRecord) Object(name string, value JSONMarshaller) *JsonLogRecord
- func (record *JsonLogRecord) Panic(msg string, args ...any)
- func (record *JsonLogRecord) String(name string, value string) *JsonLogRecord
- func (record *JsonLogRecord) StringArray(name string, value []string) *JsonLogRecord
- func (record *JsonLogRecord) Trace(msg string, args ...any)
- func (record *JsonLogRecord) UInt(name string, value uint) *JsonLogRecord
- func (record *JsonLogRecord) UInt8(name string, value uint8) *JsonLogRecord
- func (record *JsonLogRecord) UInt8Array(name string, value []uint8) *JsonLogRecord
- func (record *JsonLogRecord) UInt16(name string, value uint16) *JsonLogRecord
- func (record *JsonLogRecord) UInt16Array(name string, value []uint16) *JsonLogRecord
- func (record *JsonLogRecord) UInt32(name string, value uint32) *JsonLogRecord
- func (record *JsonLogRecord) UInt32Array(name string, value []uint32) *JsonLogRecord
- func (record *JsonLogRecord) UInt64(name string, value uint64) *JsonLogRecord
- func (record *JsonLogRecord) UInt64Array(name string, value []uint64) *JsonLogRecord
- func (record *JsonLogRecord) UIntArray(name string, value []uint) *JsonLogRecord
- func (record *JsonLogRecord) Warning(msg string, args ...any)
- func (record *JsonLogRecord) With(name string, value any) IAttributeLogger
- func (record *JsonLogRecord) WithContextValues(ctx context.Context, keys ...any) IAttributeLogger
- type LogFormat
- type LogLevel
- type LogRecord
- func (record *LogRecord) Debug(msg string, args ...any)
- func (record *LogRecord) Error(msg string, args ...any)
- func (record *LogRecord) Fatal(msg string, args ...any)
- func (record *LogRecord) Info(msg string, args ...any)
- func (record *LogRecord) Log(msg string, args ...any)
- func (record *LogRecord) Panic(msg string, args ...any)
- func (record *LogRecord) Trace(msg string, args ...any)
- func (record *LogRecord) Warning(msg string, args ...any)
- func (record *LogRecord) With(name string, value any) IAttributeLogger
- func (record *LogRecord) WithContextValues(ctx context.Context, keys ...any) IAttributeLogger
- type Logger
- func (logger *Logger) Ctx(parent context.Context) context.Context
- func (logger *Logger) Debug(msg string, args ...any)
- func (logger *Logger) Error(msg string, args ...any)
- func (logger *Logger) Fatal(msg string, args ...any)
- func (logger *Logger) Info(msg string, args ...any)
- func (logger *Logger) JSON() *JsonLogRecord
- func (logger *Logger) Log(msg string, args ...any)
- func (logger *Logger) Panic(msg string, args ...any)
- func (logger *Logger) Record() *LogRecord
- func (logger *Logger) Trace(msg string, args ...any)
- func (logger *Logger) Warning(msg string, args ...any)
- func (logger *Logger) With(name string, value any) IAttributeLogger
- func (logger *Logger) WithContextValues(ctx context.Context, keys ...any) IAttributeLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IAttributeLogger ¶ added in v0.2.0
type IAttributeLogger interface {
ILogger
// With binds an attribute and returns the logging primitive that owns it.
// Logger returns a new LogRecord; records return themselves.
With(name string, value any) IAttributeLogger
// WithContextValues captures each ctx.Value(key) under the fmt.Sprint(key)
// name and returns the logging primitive that owns the attributes. Keys that
// are nil or absent from the context are ignored.
WithContextValues(ctx context.Context, keys ...any) IAttributeLogger
}
IAttributeLogger describes a logger that can bind attributes to a log event.
type ILogger ¶ added in v0.2.0
type ILogger interface {
Log(msg string, args ...any)
Trace(msg string, args ...any)
Debug(msg string, args ...any)
Info(msg string, args ...any)
Warning(msg string, args ...any)
Error(msg string, args ...any)
Fatal(msg string, args ...any)
Panic(msg string, args ...any)
}
ILogger describes all logging primitives exposed by author.
type JSONMarshaller ¶
type JSONMarshaller interface {
Marshall(*JsonLogRecord)
}
JSONMarshaller writes the fields of a nested JSON object.
type JSONRecord ¶
type JSONRecord = JsonLogRecord
JSONRecord is retained as a source-compatible alias.
type JsonLogRecord ¶ added in v0.2.0
type JsonLogRecord struct {
// contains filtered or unexported fields
}
JsonLogRecord is a single-goroutine, single-use structured record bound to a Logger. It owns the complete JSON event buffer; a log method writes that buffer directly, then returns the record to its internal pool.
func NewJSONLogRecord ¶ added in v0.2.0
func NewJSONLogRecord(logger *Logger) *JsonLogRecord
NewJSONLogRecord acquires a single-use JSON record bound to logger.
func (*JsonLogRecord) Bool ¶ added in v0.2.0
func (record *JsonLogRecord) Bool(name string, value bool) *JsonLogRecord
func (*JsonLogRecord) BoolArray ¶ added in v0.2.0
func (record *JsonLogRecord) BoolArray(name string, value []bool) *JsonLogRecord
func (*JsonLogRecord) Byte ¶ added in v0.2.0
func (record *JsonLogRecord) Byte(name string, value byte) *JsonLogRecord
func (*JsonLogRecord) ByteArray ¶ added in v0.2.0
func (record *JsonLogRecord) ByteArray(name string, value []byte) *JsonLogRecord
func (*JsonLogRecord) Bytes ¶ added in v0.2.0
func (record *JsonLogRecord) Bytes(name string, value []byte) *JsonLogRecord
func (*JsonLogRecord) Debug ¶ added in v0.2.0
func (record *JsonLogRecord) Debug(msg string, args ...any)
func (*JsonLogRecord) Error ¶ added in v0.2.0
func (record *JsonLogRecord) Error(msg string, args ...any)
func (*JsonLogRecord) Fatal ¶ added in v0.2.0
func (record *JsonLogRecord) Fatal(msg string, args ...any)
func (*JsonLogRecord) Float32 ¶ added in v0.2.0
func (record *JsonLogRecord) Float32(name string, value float32) *JsonLogRecord
func (*JsonLogRecord) Float32Array ¶ added in v0.2.0
func (record *JsonLogRecord) Float32Array(name string, value []float32) *JsonLogRecord
func (*JsonLogRecord) Float64 ¶ added in v0.2.0
func (record *JsonLogRecord) Float64(name string, value float64) *JsonLogRecord
func (*JsonLogRecord) Float64Array ¶ added in v0.2.0
func (record *JsonLogRecord) Float64Array(name string, value []float64) *JsonLogRecord
func (*JsonLogRecord) Info ¶ added in v0.2.0
func (record *JsonLogRecord) Info(msg string, args ...any)
func (*JsonLogRecord) Int ¶ added in v0.2.0
func (record *JsonLogRecord) Int(name string, value int) *JsonLogRecord
func (*JsonLogRecord) Int8 ¶ added in v0.2.0
func (record *JsonLogRecord) Int8(name string, value int8) *JsonLogRecord
func (*JsonLogRecord) Int8Array ¶ added in v0.2.0
func (record *JsonLogRecord) Int8Array(name string, value []int8) *JsonLogRecord
func (*JsonLogRecord) Int16 ¶ added in v0.2.0
func (record *JsonLogRecord) Int16(name string, value int16) *JsonLogRecord
func (*JsonLogRecord) Int16Array ¶ added in v0.2.0
func (record *JsonLogRecord) Int16Array(name string, value []int16) *JsonLogRecord
func (*JsonLogRecord) Int32 ¶ added in v0.2.0
func (record *JsonLogRecord) Int32(name string, value int32) *JsonLogRecord
func (*JsonLogRecord) Int32Array ¶ added in v0.2.0
func (record *JsonLogRecord) Int32Array(name string, value []int32) *JsonLogRecord
func (*JsonLogRecord) Int64 ¶ added in v0.2.0
func (record *JsonLogRecord) Int64(name string, value int64) *JsonLogRecord
func (*JsonLogRecord) Int64Array ¶ added in v0.2.0
func (record *JsonLogRecord) Int64Array(name string, value []int64) *JsonLogRecord
func (*JsonLogRecord) IntArray ¶ added in v0.2.0
func (record *JsonLogRecord) IntArray(name string, value []int) *JsonLogRecord
func (*JsonLogRecord) Log ¶ added in v0.2.0
func (record *JsonLogRecord) Log(msg string, args ...any)
func (*JsonLogRecord) Object ¶ added in v0.2.0
func (record *JsonLogRecord) Object(name string, value JSONMarshaller) *JsonLogRecord
func (*JsonLogRecord) Panic ¶ added in v0.2.0
func (record *JsonLogRecord) Panic(msg string, args ...any)
func (*JsonLogRecord) String ¶ added in v0.2.0
func (record *JsonLogRecord) String(name string, value string) *JsonLogRecord
func (*JsonLogRecord) StringArray ¶ added in v0.2.0
func (record *JsonLogRecord) StringArray(name string, value []string) *JsonLogRecord
func (*JsonLogRecord) Trace ¶ added in v0.2.0
func (record *JsonLogRecord) Trace(msg string, args ...any)
func (*JsonLogRecord) UInt ¶ added in v0.2.0
func (record *JsonLogRecord) UInt(name string, value uint) *JsonLogRecord
func (*JsonLogRecord) UInt8 ¶ added in v0.2.0
func (record *JsonLogRecord) UInt8(name string, value uint8) *JsonLogRecord
func (*JsonLogRecord) UInt8Array ¶ added in v0.2.0
func (record *JsonLogRecord) UInt8Array(name string, value []uint8) *JsonLogRecord
func (*JsonLogRecord) UInt16 ¶ added in v0.2.0
func (record *JsonLogRecord) UInt16(name string, value uint16) *JsonLogRecord
func (*JsonLogRecord) UInt16Array ¶ added in v0.2.0
func (record *JsonLogRecord) UInt16Array(name string, value []uint16) *JsonLogRecord
func (*JsonLogRecord) UInt32 ¶ added in v0.2.0
func (record *JsonLogRecord) UInt32(name string, value uint32) *JsonLogRecord
func (*JsonLogRecord) UInt32Array ¶ added in v0.2.0
func (record *JsonLogRecord) UInt32Array(name string, value []uint32) *JsonLogRecord
func (*JsonLogRecord) UInt64 ¶ added in v0.2.0
func (record *JsonLogRecord) UInt64(name string, value uint64) *JsonLogRecord
func (*JsonLogRecord) UInt64Array ¶ added in v0.2.0
func (record *JsonLogRecord) UInt64Array(name string, value []uint64) *JsonLogRecord
func (*JsonLogRecord) UIntArray ¶ added in v0.2.0
func (record *JsonLogRecord) UIntArray(name string, value []uint) *JsonLogRecord
func (*JsonLogRecord) Warning ¶ added in v0.2.0
func (record *JsonLogRecord) Warning(msg string, args ...any)
func (*JsonLogRecord) With ¶ added in v0.2.0
func (record *JsonLogRecord) With(name string, value any) IAttributeLogger
With adds an attribute to record and returns record for fluent calls.
func (*JsonLogRecord) WithContextValues ¶ added in v0.2.0
func (record *JsonLogRecord) WithContextValues(ctx context.Context, keys ...any) IAttributeLogger
WithContextValues adds selected context values and returns record.
type LogRecord ¶ added in v0.2.0
type LogRecord struct {
// contains filtered or unexported fields
}
LogRecord is a single-goroutine, single-use set of attributes bound to a Logger. A log method is terminal and returns the record to its internal pool.
func (*LogRecord) With ¶ added in v0.2.0
func (record *LogRecord) With(name string, value any) IAttributeLogger
With adds an attribute to record and returns record for fluent calls.
func (*LogRecord) WithContextValues ¶ added in v0.2.0
func (record *LogRecord) WithContextValues(ctx context.Context, keys ...any) IAttributeLogger
WithContextValues adds selected context values and returns record.
type Logger ¶
type Logger struct {
Config
// contains filtered or unexported fields
}
func (*Logger) JSON ¶
func (logger *Logger) JSON() *JsonLogRecord
JSON acquires a single-use JSON record bound to logger.
func (*Logger) Record ¶ added in v0.2.0
Record acquires a single-use attribute record bound to logger.
func (*Logger) With ¶
func (logger *Logger) With(name string, value any) IAttributeLogger
With acquires a bound LogRecord containing the attribute.
func (*Logger) WithContextValues ¶ added in v0.2.0
func (logger *Logger) WithContextValues(ctx context.Context, keys ...any) IAttributeLogger
WithContextValues acquires a bound LogRecord containing the selected values.