Documentation ¶
Index ¶
- Variables
- type CLILogBuilder
- func (plb *CLILogBuilder) Any(key string, val any) LogBuilder
- func (plb *CLILogBuilder) Bool(key string, val bool) LogBuilder
- func (plb *CLILogBuilder) Bytes(key string, b []byte) LogBuilder
- func (plb *CLILogBuilder) Err(err error) LogBuilder
- func (plb *CLILogBuilder) Float32(key string, val float32) LogBuilder
- func (plb *CLILogBuilder) Float64(key string, val float64) LogBuilder
- func (plb *CLILogBuilder) Int(key string, val int) LogBuilder
- func (plb *CLILogBuilder) Int16(key string, val int16) LogBuilder
- func (plb *CLILogBuilder) Int32(key string, val int32) LogBuilder
- func (plb *CLILogBuilder) Int64(key string, val int64) LogBuilder
- func (plb *CLILogBuilder) Int8(key string, val int8) LogBuilder
- func (plb *CLILogBuilder) Send()
- func (plb *CLILogBuilder) Str(key, val string) LogBuilder
- func (plb *CLILogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
- func (plb *CLILogBuilder) Timestamp() LogBuilder
- func (plb *CLILogBuilder) Uint(key string, val uint) LogBuilder
- func (plb *CLILogBuilder) Uint16(key string, val uint16) LogBuilder
- func (plb *CLILogBuilder) Uint32(key string, val uint32) LogBuilder
- func (plb *CLILogBuilder) Uint64(key string, val uint64) LogBuilder
- func (plb *CLILogBuilder) Uint8(key string, val uint8) LogBuilder
- type CLILogger
- func (pl *CLILogger) Debug(msg string) LogBuilder
- func (pl *CLILogger) Debugf(format string, v ...any) LogBuilder
- func (pl *CLILogger) Error(msg string) LogBuilder
- func (pl *CLILogger) Errorf(format string, v ...any) LogBuilder
- func (pl *CLILogger) Fatal(msg string) LogBuilder
- func (pl *CLILogger) Fatalf(format string, v ...any) LogBuilder
- func (pl *CLILogger) Info(msg string) LogBuilder
- func (pl *CLILogger) Infof(format string, v ...any) LogBuilder
- func (pl *CLILogger) NoExit()
- func (pl *CLILogger) NoPanic()
- func (pl *CLILogger) Panic(msg string) LogBuilder
- func (pl *CLILogger) Panicf(format string, v ...any) LogBuilder
- func (pl *CLILogger) SetLevel(l LogLevel)
- func (pl *CLILogger) Warn(msg string) LogBuilder
- func (pl *CLILogger) Warnf(format string, v ...any) LogBuilder
- type JSONLogBuilder
- func (jlb *JSONLogBuilder) Any(key string, val any) LogBuilder
- func (jlb *JSONLogBuilder) Bool(key string, val bool) LogBuilder
- func (jlb *JSONLogBuilder) Bytes(key string, b []byte) LogBuilder
- func (jlb *JSONLogBuilder) Err(err error) LogBuilder
- func (jlb *JSONLogBuilder) Float32(key string, val float32) LogBuilder
- func (jlb *JSONLogBuilder) Float64(key string, val float64) LogBuilder
- func (jlb *JSONLogBuilder) Int(key string, val int) LogBuilder
- func (jlb *JSONLogBuilder) Int16(key string, val int16) LogBuilder
- func (jlb *JSONLogBuilder) Int32(key string, val int32) LogBuilder
- func (jlb *JSONLogBuilder) Int64(key string, val int64) LogBuilder
- func (jlb *JSONLogBuilder) Int8(key string, val int8) LogBuilder
- func (jlb *JSONLogBuilder) Send()
- func (jlb *JSONLogBuilder) Str(key, val string) LogBuilder
- func (jlb *JSONLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
- func (jlb *JSONLogBuilder) Timestamp() LogBuilder
- func (jlb *JSONLogBuilder) Uint(key string, val uint) LogBuilder
- func (jlb *JSONLogBuilder) Uint16(key string, val uint16) LogBuilder
- func (jlb *JSONLogBuilder) Uint32(key string, val uint32) LogBuilder
- func (jlb *JSONLogBuilder) Uint64(key string, val uint64) LogBuilder
- func (jlb *JSONLogBuilder) Uint8(key string, val uint8) LogBuilder
- type JSONLogger
- func (jl *JSONLogger) Debug(msg string) LogBuilder
- func (jl *JSONLogger) Debugf(format string, v ...any) LogBuilder
- func (jl *JSONLogger) Error(msg string) LogBuilder
- func (jl *JSONLogger) Errorf(format string, v ...any) LogBuilder
- func (jl *JSONLogger) Fatal(msg string) LogBuilder
- func (jl *JSONLogger) Fatalf(format string, v ...any) LogBuilder
- func (jl *JSONLogger) Info(msg string) LogBuilder
- func (jl *JSONLogger) Infof(format string, v ...any) LogBuilder
- func (jl *JSONLogger) NoExit()
- func (jl *JSONLogger) NoPanic()
- func (jl *JSONLogger) Panic(msg string) LogBuilder
- func (jl *JSONLogger) Panicf(format string, v ...any) LogBuilder
- func (jl *JSONLogger) SetLevel(l LogLevel)
- func (jl *JSONLogger) Warn(msg string) LogBuilder
- func (jl *JSONLogger) Warnf(format string, v ...any) LogBuilder
- type LogBuilder
- type LogLevel
- type Logger
- type MultiLogBuilder
- func (mlb *MultiLogBuilder) Any(key string, val any) LogBuilder
- func (mlb *MultiLogBuilder) Bool(key string, val bool) LogBuilder
- func (mlb *MultiLogBuilder) Bytes(key string, b []byte) LogBuilder
- func (mlb *MultiLogBuilder) Err(err error) LogBuilder
- func (mlb *MultiLogBuilder) Float32(key string, val float32) LogBuilder
- func (mlb *MultiLogBuilder) Float64(key string, val float64) LogBuilder
- func (mlb *MultiLogBuilder) Int(key string, val int) LogBuilder
- func (mlb *MultiLogBuilder) Int16(key string, val int16) LogBuilder
- func (mlb *MultiLogBuilder) Int32(key string, val int32) LogBuilder
- func (mlb *MultiLogBuilder) Int64(key string, val int64) LogBuilder
- func (mlb *MultiLogBuilder) Int8(key string, val int8) LogBuilder
- func (mlb *MultiLogBuilder) Send()
- func (mlb *MultiLogBuilder) Str(key, val string) LogBuilder
- func (mlb *MultiLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
- func (mlb *MultiLogBuilder) Timestamp() LogBuilder
- func (mlb *MultiLogBuilder) Uint(key string, val uint) LogBuilder
- func (mlb *MultiLogBuilder) Uint16(key string, val uint16) LogBuilder
- func (mlb *MultiLogBuilder) Uint32(key string, val uint32) LogBuilder
- func (mlb *MultiLogBuilder) Uint64(key string, val uint64) LogBuilder
- func (mlb *MultiLogBuilder) Uint8(key string, val uint8) LogBuilder
- type MultiLogger
- func (ml *MultiLogger) Debug(msg string) LogBuilder
- func (ml *MultiLogger) Debugf(format string, v ...any) LogBuilder
- func (ml *MultiLogger) Error(msg string) LogBuilder
- func (ml *MultiLogger) Errorf(format string, v ...any) LogBuilder
- func (ml *MultiLogger) Fatal(msg string) LogBuilder
- func (ml *MultiLogger) Fatalf(format string, v ...any) LogBuilder
- func (ml *MultiLogger) Info(msg string) LogBuilder
- func (ml *MultiLogger) Infof(format string, v ...any) LogBuilder
- func (ml *MultiLogger) NoExit()
- func (ml *MultiLogger) NoPanic()
- func (ml *MultiLogger) Panic(msg string) LogBuilder
- func (ml *MultiLogger) Panicf(format string, v ...any) LogBuilder
- func (ml *MultiLogger) SetLevel(l LogLevel)
- func (ml *MultiLogger) Warn(msg string) LogBuilder
- func (ml *MultiLogger) Warnf(format string, v ...any) LogBuilder
- type NopLogBuilder
- func (nlb NopLogBuilder) Any(key string, val any) LogBuilder
- func (nlb NopLogBuilder) Bool(key string, val bool) LogBuilder
- func (nlb NopLogBuilder) Bytes(key string, b []byte) LogBuilder
- func (nlb NopLogBuilder) Err(err error) LogBuilder
- func (nlb NopLogBuilder) Float32(key string, val float32) LogBuilder
- func (nlb NopLogBuilder) Float64(key string, val float64) LogBuilder
- func (nlb NopLogBuilder) Int(key string, val int) LogBuilder
- func (nlb NopLogBuilder) Int16(key string, val int16) LogBuilder
- func (nlb NopLogBuilder) Int32(key string, val int32) LogBuilder
- func (nlb NopLogBuilder) Int64(key string, val int64) LogBuilder
- func (nlb NopLogBuilder) Int8(key string, val int8) LogBuilder
- func (nlb NopLogBuilder) Send()
- func (nlb NopLogBuilder) Str(key, val string) LogBuilder
- func (nlb NopLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
- func (nlb NopLogBuilder) Timestamp() LogBuilder
- func (nlb NopLogBuilder) Uint(key string, val uint) LogBuilder
- func (nlb NopLogBuilder) Uint16(key string, val uint16) LogBuilder
- func (nlb NopLogBuilder) Uint32(key string, val uint32) LogBuilder
- func (nlb NopLogBuilder) Uint64(key string, val uint64) LogBuilder
- func (nlb NopLogBuilder) Uint8(key string, val uint8) LogBuilder
- type NopLogger
- func (nl NopLogger) Debug(msg string) LogBuilder
- func (nl NopLogger) Debugf(format string, v ...any) LogBuilder
- func (nl NopLogger) Error(msg string) LogBuilder
- func (nl NopLogger) Errorf(format string, v ...any) LogBuilder
- func (nl NopLogger) Fatal(msg string) LogBuilder
- func (nl NopLogger) Fatalf(format string, v ...any) LogBuilder
- func (nl NopLogger) Info(msg string) LogBuilder
- func (nl NopLogger) Infof(format string, v ...any) LogBuilder
- func (nl NopLogger) NoExit()
- func (nl NopLogger) NoPanic()
- func (nl NopLogger) Panic(msg string) LogBuilder
- func (nl NopLogger) Panicf(format string, v ...any) LogBuilder
- func (nl NopLogger) SetLevel(LogLevel)
- func (nl NopLogger) Warn(msg string) LogBuilder
- func (nl NopLogger) Warnf(format string, v ...any) LogBuilder
- type PrettyLogBuilder
- func (plb *PrettyLogBuilder) Any(key string, val any) LogBuilder
- func (plb *PrettyLogBuilder) Bool(key string, val bool) LogBuilder
- func (plb *PrettyLogBuilder) Bytes(key string, b []byte) LogBuilder
- func (plb *PrettyLogBuilder) Err(err error) LogBuilder
- func (plb *PrettyLogBuilder) Float32(key string, val float32) LogBuilder
- func (plb *PrettyLogBuilder) Float64(key string, val float64) LogBuilder
- func (plb *PrettyLogBuilder) Int(key string, val int) LogBuilder
- func (plb *PrettyLogBuilder) Int16(key string, val int16) LogBuilder
- func (plb *PrettyLogBuilder) Int32(key string, val int32) LogBuilder
- func (plb *PrettyLogBuilder) Int64(key string, val int64) LogBuilder
- func (plb *PrettyLogBuilder) Int8(key string, val int8) LogBuilder
- func (plb *PrettyLogBuilder) Send()
- func (plb *PrettyLogBuilder) Str(key, val string) LogBuilder
- func (plb *PrettyLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
- func (plb *PrettyLogBuilder) Timestamp() LogBuilder
- func (plb *PrettyLogBuilder) Uint(key string, val uint) LogBuilder
- func (plb *PrettyLogBuilder) Uint16(key string, val uint16) LogBuilder
- func (plb *PrettyLogBuilder) Uint32(key string, val uint32) LogBuilder
- func (plb *PrettyLogBuilder) Uint64(key string, val uint64) LogBuilder
- func (plb *PrettyLogBuilder) Uint8(key string, val uint8) LogBuilder
- type PrettyLogger
- func (pl *PrettyLogger) Debug(msg string) LogBuilder
- func (pl *PrettyLogger) Debugf(format string, v ...any) LogBuilder
- func (pl *PrettyLogger) Error(msg string) LogBuilder
- func (pl *PrettyLogger) Errorf(format string, v ...any) LogBuilder
- func (pl *PrettyLogger) Fatal(msg string) LogBuilder
- func (pl *PrettyLogger) Fatalf(format string, v ...any) LogBuilder
- func (pl *PrettyLogger) Info(msg string) LogBuilder
- func (pl *PrettyLogger) Infof(format string, v ...any) LogBuilder
- func (pl *PrettyLogger) NoExit()
- func (pl *PrettyLogger) NoPanic()
- func (pl *PrettyLogger) Panic(msg string) LogBuilder
- func (pl *PrettyLogger) Panicf(format string, v ...any) LogBuilder
- func (pl *PrettyLogger) SetLevel(l LogLevel)
- func (pl *PrettyLogger) Warn(msg string) LogBuilder
- func (pl *PrettyLogger) Warnf(format string, v ...any) LogBuilder
Constants ¶
This section is empty.
Variables ¶
ErrNoSuchLevel is returned when ParseLogLevel cannot find a log level corresponding to the provided string
Functions ¶
This section is empty.
Types ¶
type CLILogBuilder ¶
type CLILogBuilder struct {
// contains filtered or unexported fields
}
CLILogBuilder implements the LogBuilder interface using human-readable output for log messages
func (*CLILogBuilder) Any ¶
func (plb *CLILogBuilder) Any(key string, val any) LogBuilder
Any uses reflection to marshal any type and writes the result as a field to the output. This is much slower than the type-specific functions.
func (*CLILogBuilder) Bool ¶
func (plb *CLILogBuilder) Bool(key string, val bool) LogBuilder
Bool adds a bool as a field to the output
func (*CLILogBuilder) Bytes ¶
func (plb *CLILogBuilder) Bytes(key string, b []byte) LogBuilder
Bytes writes hex-encoded bytes as a field to the output
func (*CLILogBuilder) Err ¶
func (plb *CLILogBuilder) Err(err error) LogBuilder
Err adds an error as a field to the output
func (*CLILogBuilder) Float32 ¶
func (plb *CLILogBuilder) Float32(key string, val float32) LogBuilder
Float32 adds a float32 field to the output
func (*CLILogBuilder) Float64 ¶
func (plb *CLILogBuilder) Float64(key string, val float64) LogBuilder
Float64 adds a float64 field to the output
func (*CLILogBuilder) Int ¶
func (plb *CLILogBuilder) Int(key string, val int) LogBuilder
Int adds an int field to the output
func (*CLILogBuilder) Int16 ¶
func (plb *CLILogBuilder) Int16(key string, val int16) LogBuilder
Int16 adds an int16 field to the output
func (*CLILogBuilder) Int32 ¶
func (plb *CLILogBuilder) Int32(key string, val int32) LogBuilder
Int32 adds an int32 field to the output
func (*CLILogBuilder) Int64 ¶
func (plb *CLILogBuilder) Int64(key string, val int64) LogBuilder
Int64 adds an int64 field to the output
func (*CLILogBuilder) Int8 ¶
func (plb *CLILogBuilder) Int8(key string, val int8) LogBuilder
Int8 adds an int8 field to the output
func (*CLILogBuilder) Send ¶
func (plb *CLILogBuilder) Send()
Send sends the event to the output.
After calling send, do not use the event again.
func (*CLILogBuilder) Str ¶
func (plb *CLILogBuilder) Str(key, val string) LogBuilder
Str adds a string as a field to the output
func (*CLILogBuilder) Stringer ¶
func (plb *CLILogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
Stringer calls the String method of an fmt.Stringer and adds the resulting string as a field to the output
func (*CLILogBuilder) Timestamp ¶
func (plb *CLILogBuilder) Timestamp() LogBuilder
Timestamp adds the time formatted as RFC3339Nano as a field to the output
func (*CLILogBuilder) Uint ¶
func (plb *CLILogBuilder) Uint(key string, val uint) LogBuilder
Uint adds a uint field to the output
func (*CLILogBuilder) Uint16 ¶
func (plb *CLILogBuilder) Uint16(key string, val uint16) LogBuilder
Uint16 adds a uint16 field to the output
func (*CLILogBuilder) Uint32 ¶
func (plb *CLILogBuilder) Uint32(key string, val uint32) LogBuilder
Uint32 adds a uint32 field to the output
func (*CLILogBuilder) Uint64 ¶
func (plb *CLILogBuilder) Uint64(key string, val uint64) LogBuilder
Uint64 adds a uint64 field to the output
func (*CLILogBuilder) Uint8 ¶
func (plb *CLILogBuilder) Uint8(key string, val uint8) LogBuilder
Uint8 adds a uint8 field to the output
type CLILogger ¶
type CLILogger struct { Out io.Writer Level LogLevel UseColor bool MsgColor color.Color KeyColor color.Color DebugColor color.Color InfoColor color.Color WarnColor color.Color ErrColor color.Color FatalColor color.Color PanicColor color.Color // contains filtered or unexported fields }
CLILogger is a logger meant to be used for CLI tools where users will view and read the logs throughout the application's execution
func (*CLILogger) Debug ¶
func (pl *CLILogger) Debug(msg string) LogBuilder
Debug creates a new debug event with the given message
func (*CLILogger) Debugf ¶
func (pl *CLILogger) Debugf(format string, v ...any) LogBuilder
Debugf creates a new debug event with the formatted message
func (*CLILogger) Error ¶
func (pl *CLILogger) Error(msg string) LogBuilder
Error creates a new error event with the given message
func (*CLILogger) Errorf ¶
func (pl *CLILogger) Errorf(format string, v ...any) LogBuilder
Errorf creates a new error event with the formatted message
func (*CLILogger) Fatal ¶
func (pl *CLILogger) Fatal(msg string) LogBuilder
Fatal creates a new fatal event with the given message
When sent, fatal events will cause a call to os.Exit(1)
func (*CLILogger) Fatalf ¶
func (pl *CLILogger) Fatalf(format string, v ...any) LogBuilder
Fatalf creates a new fatal event with the formatted message
When sent, fatal events will cause a call to os.Exit(1)
func (*CLILogger) Info ¶
func (pl *CLILogger) Info(msg string) LogBuilder
Info creates a new info event with the given message
func (*CLILogger) Infof ¶
func (pl *CLILogger) Infof(format string, v ...any) LogBuilder
Infof creates a new info event with the formatted message
func (*CLILogger) NoExit ¶
func (pl *CLILogger) NoExit()
NoExit prevents the logger from exiting on fatal events
func (*CLILogger) NoPanic ¶
func (pl *CLILogger) NoPanic()
NoPanic prevents the logger from panicking on panic events
func (*CLILogger) Panic ¶
func (pl *CLILogger) Panic(msg string) LogBuilder
Panic creates a new panic event with the given message
When sent, panic events will cause a panic
func (*CLILogger) Panicf ¶
func (pl *CLILogger) Panicf(format string, v ...any) LogBuilder
Panicf creates a new panic event with the formatted message
When sent, panic events will cause a panic
func (*CLILogger) SetLevel ¶
SetLevel sets the log level of the logger
func (*CLILogger) Warn ¶
func (pl *CLILogger) Warn(msg string) LogBuilder
Warn creates a new warn event with the given message
func (*CLILogger) Warnf ¶
func (pl *CLILogger) Warnf(format string, v ...any) LogBuilder
Warnf creates a new warn event with the formatted message
type JSONLogBuilder ¶
type JSONLogBuilder struct {
// contains filtered or unexported fields
}
JSONLogBuilder implements the LogBuilder interface using JSON for log messages
func (*JSONLogBuilder) Any ¶
func (jlb *JSONLogBuilder) Any(key string, val any) LogBuilder
Any uses reflection to marshal any type and writes the result as a field to the output. This is much slower than the type-specific functions.
func (*JSONLogBuilder) Bool ¶
func (jlb *JSONLogBuilder) Bool(key string, val bool) LogBuilder
Bool adds a bool as a field to the output
func (*JSONLogBuilder) Bytes ¶
func (jlb *JSONLogBuilder) Bytes(key string, b []byte) LogBuilder
Bytes writes base64-encoded bytes as a field to the output
func (*JSONLogBuilder) Err ¶
func (jlb *JSONLogBuilder) Err(err error) LogBuilder
Err adds an error as a field to the output
func (*JSONLogBuilder) Float32 ¶
func (jlb *JSONLogBuilder) Float32(key string, val float32) LogBuilder
Float32 adds a float32 field to the output
func (*JSONLogBuilder) Float64 ¶
func (jlb *JSONLogBuilder) Float64(key string, val float64) LogBuilder
Float64 adds a float64 field to the output
func (*JSONLogBuilder) Int ¶
func (jlb *JSONLogBuilder) Int(key string, val int) LogBuilder
Int adds an int field to the output
func (*JSONLogBuilder) Int16 ¶
func (jlb *JSONLogBuilder) Int16(key string, val int16) LogBuilder
Int16 adds an int16 field to the output
func (*JSONLogBuilder) Int32 ¶
func (jlb *JSONLogBuilder) Int32(key string, val int32) LogBuilder
Int32 adds an int32 field to the output
func (*JSONLogBuilder) Int64 ¶
func (jlb *JSONLogBuilder) Int64(key string, val int64) LogBuilder
Int64 adds an int64 field to the output
func (*JSONLogBuilder) Int8 ¶
func (jlb *JSONLogBuilder) Int8(key string, val int8) LogBuilder
Int8 adds an int8 field to the output
func (*JSONLogBuilder) Send ¶
func (jlb *JSONLogBuilder) Send()
Send sends the event to the output.
After calling send, do not use the event again.
func (*JSONLogBuilder) Str ¶
func (jlb *JSONLogBuilder) Str(key, val string) LogBuilder
Str adds a string as a field to the output
func (*JSONLogBuilder) Stringer ¶
func (jlb *JSONLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
Stringer calls the String method of an fmt.Stringer and adds the resulting string as a field to the output
func (*JSONLogBuilder) Timestamp ¶
func (jlb *JSONLogBuilder) Timestamp() LogBuilder
Timestamp adds the time formatted as RFC3339Nano as a field to the output using the key "timestamp"
func (*JSONLogBuilder) Uint ¶
func (jlb *JSONLogBuilder) Uint(key string, val uint) LogBuilder
Uint adds a uint field to the output
func (*JSONLogBuilder) Uint16 ¶
func (jlb *JSONLogBuilder) Uint16(key string, val uint16) LogBuilder
Uint16 adds a uint16 field to the output
func (*JSONLogBuilder) Uint32 ¶
func (jlb *JSONLogBuilder) Uint32(key string, val uint32) LogBuilder
Uint32 adds a uint32 field to the output
func (*JSONLogBuilder) Uint64 ¶
func (jlb *JSONLogBuilder) Uint64(key string, val uint64) LogBuilder
Uint64 adds a uint64 field to the output
func (*JSONLogBuilder) Uint8 ¶
func (jlb *JSONLogBuilder) Uint8(key string, val uint8) LogBuilder
Uint8 adds a uint8 field to the output
type JSONLogger ¶
JSONLogger implements the Logger interface using JSON for log messages.
func NewJSON ¶
func NewJSON(out io.Writer) *JSONLogger
NewJSON creates and returns a new JSONLogger If the input writer is io.Discard, NopLogger will be returned.
func (*JSONLogger) Debug ¶
func (jl *JSONLogger) Debug(msg string) LogBuilder
Debug creates a new debug event with the given message
func (*JSONLogger) Debugf ¶
func (jl *JSONLogger) Debugf(format string, v ...any) LogBuilder
Debugf creates a new debug event with the formatted message
func (*JSONLogger) Error ¶
func (jl *JSONLogger) Error(msg string) LogBuilder
Error creates a new error event with the given message
func (*JSONLogger) Errorf ¶
func (jl *JSONLogger) Errorf(format string, v ...any) LogBuilder
Errorf creates a new error event with the formatted message
func (*JSONLogger) Fatal ¶
func (jl *JSONLogger) Fatal(msg string) LogBuilder
Fatal creates a new fatal event with the given message
When sent, fatal events will cause a call to os.Exit(1)
func (*JSONLogger) Fatalf ¶
func (jl *JSONLogger) Fatalf(format string, v ...any) LogBuilder
Fatalf creates a new fatal event with the formatted message
When sent, fatal events will cause a call to os.Exit(1)
func (*JSONLogger) Info ¶
func (jl *JSONLogger) Info(msg string) LogBuilder
Info creates a new info event with the given message
func (*JSONLogger) Infof ¶
func (jl *JSONLogger) Infof(format string, v ...any) LogBuilder
Infof creates a new info event with the formatted message
func (*JSONLogger) NoExit ¶
func (jl *JSONLogger) NoExit()
NoExit prevents the logger from exiting on fatal events
func (*JSONLogger) NoPanic ¶
func (jl *JSONLogger) NoPanic()
NoPanic prevents the logger from panicking on panic events
func (*JSONLogger) Panic ¶
func (jl *JSONLogger) Panic(msg string) LogBuilder
Panic creates a new panic event with the given message
When sent, panic events will cause a panic
func (*JSONLogger) Panicf ¶
func (jl *JSONLogger) Panicf(format string, v ...any) LogBuilder
Panicf creates a new panic event with the formatted message
When sent, panic events will cause a panic
func (*JSONLogger) SetLevel ¶
func (jl *JSONLogger) SetLevel(l LogLevel)
SetLevel sets the log level of the logger
func (*JSONLogger) Warn ¶
func (jl *JSONLogger) Warn(msg string) LogBuilder
Warn creates a new warn event with the given message
func (*JSONLogger) Warnf ¶
func (jl *JSONLogger) Warnf(format string, v ...any) LogBuilder
Warnf creates a new warn event with the formatted message
type LogBuilder ¶
type LogBuilder interface { // Int adds an int field to the output Int(string, int) LogBuilder // Int8 adds an int8 field to the output Int8(string, int8) LogBuilder // Int16 adds an int16 field to the output Int16(string, int16) LogBuilder // Int32 adds an int32 field to the output Int32(string, int32) LogBuilder // Int64 adds an int64 field to the output Int64(string, int64) LogBuilder // Uint adds a uint field to the output Uint(string, uint) LogBuilder // Uint8 adds a uint8 field to the output Uint8(string, uint8) LogBuilder // Uint16 adds a uint16 field to the output Uint16(string, uint16) LogBuilder // Uint32 adds a uint32 field to the output Uint32(string, uint32) LogBuilder // Uint64 adds a uint64 field to the output Uint64(string, uint64) LogBuilder // Float32 adds a float32 field to the output Float32(string, float32) LogBuilder // Float64 adds a float64 field to the output Float64(string, float64) LogBuilder // Stringer calls the String method of an fmt.Stringer // and adds the resulting string as a field to the output Stringer(string, fmt.Stringer) LogBuilder // Bytes adds []byte as a field to the output Bytes(string, []byte) LogBuilder // Timestamp adds the time formatted as RFC3339Nano // as a field to the output using the key "timestamp" Timestamp() LogBuilder // Bool adds a bool as a field to the output Bool(string, bool) LogBuilder // Str adds a string as a field to the output Str(string, string) LogBuilder // Any uses reflection to marshal any type and writes // the result as a field to the output. This is much slower // than the type-specific functions. Any(string, any) LogBuilder // Err adds an error as a field to the output Err(error) LogBuilder // Send sends the event to the output. // // After calling send, do not use the event again. Send() }
LogBuilder represents a log event builder
type LogLevel ¶
type LogLevel uint8
LogLevel represents a log level
type Logger ¶
type Logger interface { // NoPanic prevents the logger from panicking on panic events NoPanic() // NoExit prevents the logger from exiting on fatal events NoExit() // SetLevel sets the log level of the logger SetLevel(LogLevel) // Debug creates a new debug event with the given message Debug(string) LogBuilder // Debugf creates a new debug event with the formatted message Debugf(string, ...any) LogBuilder // Info creates a new info event with the given message Info(string) LogBuilder // Infof creates a new info event with the formatted message Infof(string, ...any) LogBuilder // Warn creates a new warn event with the given message Warn(string) LogBuilder // Warnf creates a new warn event with the formatted message Warnf(string, ...any) LogBuilder // Error creates a new error event with the given message Error(string) LogBuilder // Errorf creates a new error event with the formatted message Errorf(string, ...any) LogBuilder // Fatal creates a new fatal event with the given message // // When sent, fatal events will cause a call to os.Exit(1) Fatal(string) LogBuilder // Fatalf creates a new fatal event with the formatted message // // When sent, fatal events will cause a call to os.Exit(1) Fatalf(string, ...any) LogBuilder // Panic creates a new panic event with the given message // // When sent, panic events will cause a panic Panic(string) LogBuilder // Panicf creates a new panic event with the formatted message // // When sent, panic events will cause a panic Panicf(string, ...any) LogBuilder }
Logger represents a logger
type MultiLogBuilder ¶
type MultiLogBuilder struct {
// contains filtered or unexported fields
}
MultiLogBuilder implements the LogBuilder interface by writing to multiple underlying LogBuilders sequentially.
func (*MultiLogBuilder) Any ¶
func (mlb *MultiLogBuilder) Any(key string, val any) LogBuilder
Any uses reflection to marshal any type and writes the result as a field to the output. This is much slower than the type-specific functions.
func (*MultiLogBuilder) Bool ¶
func (mlb *MultiLogBuilder) Bool(key string, val bool) LogBuilder
Bool adds a bool as a field to the output
func (*MultiLogBuilder) Bytes ¶
func (mlb *MultiLogBuilder) Bytes(key string, b []byte) LogBuilder
Bytes writes base64-encoded bytes as a field to the output
func (*MultiLogBuilder) Err ¶
func (mlb *MultiLogBuilder) Err(err error) LogBuilder
Err adds an error as a field to the output
func (*MultiLogBuilder) Float32 ¶
func (mlb *MultiLogBuilder) Float32(key string, val float32) LogBuilder
Float32 adds a float32 field to the output
func (*MultiLogBuilder) Float64 ¶
func (mlb *MultiLogBuilder) Float64(key string, val float64) LogBuilder
Float64 adds a float64 field to the output
func (*MultiLogBuilder) Int ¶
func (mlb *MultiLogBuilder) Int(key string, val int) LogBuilder
Int adds an int field to the output
func (*MultiLogBuilder) Int16 ¶
func (mlb *MultiLogBuilder) Int16(key string, val int16) LogBuilder
Int16 adds an int16 field to the output
func (*MultiLogBuilder) Int32 ¶
func (mlb *MultiLogBuilder) Int32(key string, val int32) LogBuilder
Int32 adds an int32 field to the output
func (*MultiLogBuilder) Int64 ¶
func (mlb *MultiLogBuilder) Int64(key string, val int64) LogBuilder
Int64 adds an int64 field to the output
func (*MultiLogBuilder) Int8 ¶
func (mlb *MultiLogBuilder) Int8(key string, val int8) LogBuilder
Int8 adds an int8 field to the output
func (*MultiLogBuilder) Send ¶
func (mlb *MultiLogBuilder) Send()
Send sends the event to the output.
After calling send, do not use the event again.
func (*MultiLogBuilder) Str ¶
func (mlb *MultiLogBuilder) Str(key, val string) LogBuilder
Str adds a string as a field to the output
func (*MultiLogBuilder) Stringer ¶
func (mlb *MultiLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
Stringer calls the String method of an fmt.Stringer and adds the resulting string as a field to the output
func (*MultiLogBuilder) Timestamp ¶
func (mlb *MultiLogBuilder) Timestamp() LogBuilder
Timestamp adds the time formatted as RFC3339Nano as a field to the output using the key "timestamp"
func (*MultiLogBuilder) Uint ¶
func (mlb *MultiLogBuilder) Uint(key string, val uint) LogBuilder
Uint adds a uint field to the output
func (*MultiLogBuilder) Uint16 ¶
func (mlb *MultiLogBuilder) Uint16(key string, val uint16) LogBuilder
Uint16 adds a uint16 field to the output
func (*MultiLogBuilder) Uint32 ¶
func (mlb *MultiLogBuilder) Uint32(key string, val uint32) LogBuilder
Uint32 adds a uint32 field to the output
func (*MultiLogBuilder) Uint64 ¶
func (mlb *MultiLogBuilder) Uint64(key string, val uint64) LogBuilder
Uint64 adds a uint64 field to the output
func (*MultiLogBuilder) Uint8 ¶
func (mlb *MultiLogBuilder) Uint8(key string, val uint8) LogBuilder
Uint8 adds a uint8 field to the output
type MultiLogger ¶
type MultiLogger struct { Loggers []Logger // contains filtered or unexported fields }
MultiLogger implements the Logger interface by writing to multiple underlying loggers sequentially.
func NewMulti ¶
func NewMulti(l ...Logger) *MultiLogger
NewMulti creates and returns a new MultiLogger
func (*MultiLogger) Debug ¶
func (ml *MultiLogger) Debug(msg string) LogBuilder
Debug creates a new debug event with the given message
func (*MultiLogger) Debugf ¶
func (ml *MultiLogger) Debugf(format string, v ...any) LogBuilder
Debugf creates a new debug event with the formatted message
func (*MultiLogger) Error ¶
func (ml *MultiLogger) Error(msg string) LogBuilder
Error creates a new error event with the given message
func (*MultiLogger) Errorf ¶
func (ml *MultiLogger) Errorf(format string, v ...any) LogBuilder
Errorf creates a new error event with the formatted message
func (*MultiLogger) Fatal ¶
func (ml *MultiLogger) Fatal(msg string) LogBuilder
Error creates a new error event with the given message
func (*MultiLogger) Fatalf ¶
func (ml *MultiLogger) Fatalf(format string, v ...any) LogBuilder
Errorf creates a new error event with the formatted message
func (*MultiLogger) Info ¶
func (ml *MultiLogger) Info(msg string) LogBuilder
Info creates a new info event with the given message
func (*MultiLogger) Infof ¶
func (ml *MultiLogger) Infof(format string, v ...any) LogBuilder
Infof creates a new info event with the formatted message
func (*MultiLogger) NoExit ¶
func (ml *MultiLogger) NoExit()
NoExit prevents the logger from exiting on fatal events
func (*MultiLogger) NoPanic ¶
func (ml *MultiLogger) NoPanic()
NoPanic prevents the logger from panicking on panic events
func (*MultiLogger) Panic ¶
func (ml *MultiLogger) Panic(msg string) LogBuilder
Error creates a new error event with the given message
func (*MultiLogger) Panicf ¶
func (ml *MultiLogger) Panicf(format string, v ...any) LogBuilder
Errorf creates a new error event with the formatted message
func (*MultiLogger) SetLevel ¶
func (ml *MultiLogger) SetLevel(l LogLevel)
SetLevel sets the log level of the logger
func (*MultiLogger) Warn ¶
func (ml *MultiLogger) Warn(msg string) LogBuilder
Warn creates a new warn event with the given message
func (*MultiLogger) Warnf ¶
func (ml *MultiLogger) Warnf(format string, v ...any) LogBuilder
Warnf creates a new warn event with the formatted message
type NopLogBuilder ¶
type NopLogBuilder struct{}
NopLogBuilder implements the LogBuilder interface using human-readable output for log messages
func (NopLogBuilder) Any ¶
func (nlb NopLogBuilder) Any(key string, val any) LogBuilder
Any uses reflection to marshal any type and writes the result as a field to the output. This is much slower than the type-specific functions.
func (NopLogBuilder) Bool ¶
func (nlb NopLogBuilder) Bool(key string, val bool) LogBuilder
Bool adds a bool as a field to the output
func (NopLogBuilder) Bytes ¶
func (nlb NopLogBuilder) Bytes(key string, b []byte) LogBuilder
Bytes writes hex-encoded bytes as a field to the output
func (NopLogBuilder) Err ¶
func (nlb NopLogBuilder) Err(err error) LogBuilder
Err adds an error as a field to the output
func (NopLogBuilder) Float32 ¶
func (nlb NopLogBuilder) Float32(key string, val float32) LogBuilder
Float32 adds a float32 field to the output
func (NopLogBuilder) Float64 ¶
func (nlb NopLogBuilder) Float64(key string, val float64) LogBuilder
Float64 adds a float64 field to the output
func (NopLogBuilder) Int ¶
func (nlb NopLogBuilder) Int(key string, val int) LogBuilder
Int adds an int field to the output
func (NopLogBuilder) Int16 ¶
func (nlb NopLogBuilder) Int16(key string, val int16) LogBuilder
Int16 adds an int16 field to the output
func (NopLogBuilder) Int32 ¶
func (nlb NopLogBuilder) Int32(key string, val int32) LogBuilder
Int32 adds an int32 field to the output
func (NopLogBuilder) Int64 ¶
func (nlb NopLogBuilder) Int64(key string, val int64) LogBuilder
Int64 adds an int64 field to the output
func (NopLogBuilder) Int8 ¶
func (nlb NopLogBuilder) Int8(key string, val int8) LogBuilder
Int8 adds an int8 field to the output
func (NopLogBuilder) Send ¶
func (nlb NopLogBuilder) Send()
Send sends the event to the output.
After calling send, do not use the event again.
func (NopLogBuilder) Str ¶
func (nlb NopLogBuilder) Str(key, val string) LogBuilder
Str adds a string as a field to the output
func (NopLogBuilder) Stringer ¶
func (nlb NopLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
Stringer calls the String method of an fmt.Stringer and adds the resulting string as a field to the output
func (NopLogBuilder) Timestamp ¶
func (nlb NopLogBuilder) Timestamp() LogBuilder
Timestamp adds the time formatted as RFC3339Nano as a field to the output
func (NopLogBuilder) Uint ¶
func (nlb NopLogBuilder) Uint(key string, val uint) LogBuilder
Uint adds a uint field to the output
func (NopLogBuilder) Uint16 ¶
func (nlb NopLogBuilder) Uint16(key string, val uint16) LogBuilder
Uint16 adds a uint16 field to the output
func (NopLogBuilder) Uint32 ¶
func (nlb NopLogBuilder) Uint32(key string, val uint32) LogBuilder
Uint32 adds a uint32 field to the output
func (NopLogBuilder) Uint64 ¶
func (nlb NopLogBuilder) Uint64(key string, val uint64) LogBuilder
Uint64 adds a uint64 field to the output
func (NopLogBuilder) Uint8 ¶
func (nlb NopLogBuilder) Uint8(key string, val uint8) LogBuilder
Uint8 adds a uint8 field to the output
type NopLogger ¶
type NopLogger struct{}
NopLogger implements the Logger interface using human-readable output for log messages.
func (NopLogger) Debug ¶
func (nl NopLogger) Debug(msg string) LogBuilder
Debug creates a new debug event with the given message
func (NopLogger) Debugf ¶
func (nl NopLogger) Debugf(format string, v ...any) LogBuilder
Debugf creates a new debug event with the formatted message
func (NopLogger) Error ¶
func (nl NopLogger) Error(msg string) LogBuilder
Error creates a new error event with the given message
func (NopLogger) Errorf ¶
func (nl NopLogger) Errorf(format string, v ...any) LogBuilder
Errorf creates a new error event with the formatted message
func (NopLogger) Fatal ¶
func (nl NopLogger) Fatal(msg string) LogBuilder
Fatal creates a new fatal event with the given message
func (NopLogger) Fatalf ¶
func (nl NopLogger) Fatalf(format string, v ...any) LogBuilder
Fatalf creates a new fatal event with the formatted message
func (NopLogger) Info ¶
func (nl NopLogger) Info(msg string) LogBuilder
Info creates a new info event with the given message
func (NopLogger) Infof ¶
func (nl NopLogger) Infof(format string, v ...any) LogBuilder
Infof creates a new info event with the formatted message
func (NopLogger) NoExit ¶
func (nl NopLogger) NoExit()
NoExit prevents the logger from exiting on fatal events
func (NopLogger) NoPanic ¶
func (nl NopLogger) NoPanic()
NoPanic prevents the logger from panicking on panic events
func (NopLogger) Panic ¶
func (nl NopLogger) Panic(msg string) LogBuilder
Panic creates a new panic event with the given message
func (NopLogger) Panicf ¶
func (nl NopLogger) Panicf(format string, v ...any) LogBuilder
Panicf creates a new panic event with the formatted message
func (NopLogger) SetLevel ¶
SetLevel sets the log level of the logger
func (NopLogger) Warn ¶
func (nl NopLogger) Warn(msg string) LogBuilder
Warn creates a new warn event with the given message
func (NopLogger) Warnf ¶
func (nl NopLogger) Warnf(format string, v ...any) LogBuilder
Warnf creates a new warn event with the formatted message
type PrettyLogBuilder ¶
type PrettyLogBuilder struct {
// contains filtered or unexported fields
}
PrettyLogBuilder implements the LogBuilder interface using human-readable output for log messages
func (*PrettyLogBuilder) Any ¶
func (plb *PrettyLogBuilder) Any(key string, val any) LogBuilder
Any uses reflection to marshal any type and writes the result as a field to the output. This is much slower than the type-specific functions.
func (*PrettyLogBuilder) Bool ¶
func (plb *PrettyLogBuilder) Bool(key string, val bool) LogBuilder
Bool adds a bool as a field to the output
func (*PrettyLogBuilder) Bytes ¶
func (plb *PrettyLogBuilder) Bytes(key string, b []byte) LogBuilder
Bytes writes hex-encoded bytes as a field to the output
func (*PrettyLogBuilder) Err ¶
func (plb *PrettyLogBuilder) Err(err error) LogBuilder
Err adds an error as a field to the output
func (*PrettyLogBuilder) Float32 ¶
func (plb *PrettyLogBuilder) Float32(key string, val float32) LogBuilder
Float32 adds a float32 field to the output
func (*PrettyLogBuilder) Float64 ¶
func (plb *PrettyLogBuilder) Float64(key string, val float64) LogBuilder
Float64 adds a float64 field to the output
func (*PrettyLogBuilder) Int ¶
func (plb *PrettyLogBuilder) Int(key string, val int) LogBuilder
Int adds an int field to the output
func (*PrettyLogBuilder) Int16 ¶
func (plb *PrettyLogBuilder) Int16(key string, val int16) LogBuilder
Int16 adds an int16 field to the output
func (*PrettyLogBuilder) Int32 ¶
func (plb *PrettyLogBuilder) Int32(key string, val int32) LogBuilder
Int32 adds an int32 field to the output
func (*PrettyLogBuilder) Int64 ¶
func (plb *PrettyLogBuilder) Int64(key string, val int64) LogBuilder
Int64 adds an int64 field to the output
func (*PrettyLogBuilder) Int8 ¶
func (plb *PrettyLogBuilder) Int8(key string, val int8) LogBuilder
Int8 adds an int8 field to the output
func (*PrettyLogBuilder) Send ¶
func (plb *PrettyLogBuilder) Send()
Send sends the event to the output.
After calling send, do not use the event again.
func (*PrettyLogBuilder) Str ¶
func (plb *PrettyLogBuilder) Str(key, val string) LogBuilder
Str adds a string as a field to the output
func (*PrettyLogBuilder) Stringer ¶
func (plb *PrettyLogBuilder) Stringer(key string, s fmt.Stringer) LogBuilder
Stringer calls the String method of an fmt.Stringer and adds the resulting string as a field to the output
func (*PrettyLogBuilder) Timestamp ¶
func (plb *PrettyLogBuilder) Timestamp() LogBuilder
Timestamp adds the time formatted as RFC3339Nano as a field to the output
func (*PrettyLogBuilder) Uint ¶
func (plb *PrettyLogBuilder) Uint(key string, val uint) LogBuilder
Uint adds a uint field to the output
func (*PrettyLogBuilder) Uint16 ¶
func (plb *PrettyLogBuilder) Uint16(key string, val uint16) LogBuilder
Uint16 adds a uint16 field to the output
func (*PrettyLogBuilder) Uint32 ¶
func (plb *PrettyLogBuilder) Uint32(key string, val uint32) LogBuilder
Uint32 adds a uint32 field to the output
func (*PrettyLogBuilder) Uint64 ¶
func (plb *PrettyLogBuilder) Uint64(key string, val uint64) LogBuilder
Uint64 adds a uint64 field to the output
func (*PrettyLogBuilder) Uint8 ¶
func (plb *PrettyLogBuilder) Uint8(key string, val uint8) LogBuilder
Uint8 adds a uint8 field to the output
type PrettyLogger ¶
type PrettyLogger struct { Out io.Writer Level LogLevel TimeFormat string UseColor bool TimeColor color.Color MsgColor color.Color KeyColor color.Color DebugColor color.Color InfoColor color.Color WarnColor color.Color ErrColor color.Color FatalColor color.Color PanicColor color.Color // contains filtered or unexported fields }
PrettyLogger implements the Logger interface using human-readable output for log messages.
func NewPretty ¶
func NewPretty(out io.Writer) *PrettyLogger
NewPretty creates and returns a new PrettyLogger. If the input writer is io.Discard, NopLogger will be returned.
func (*PrettyLogger) Debug ¶
func (pl *PrettyLogger) Debug(msg string) LogBuilder
Debug creates a new debug event with the given message
func (*PrettyLogger) Debugf ¶
func (pl *PrettyLogger) Debugf(format string, v ...any) LogBuilder
Debugf creates a new debug event with the formatted message
func (*PrettyLogger) Error ¶
func (pl *PrettyLogger) Error(msg string) LogBuilder
Error creates a new error event with the given message
func (*PrettyLogger) Errorf ¶
func (pl *PrettyLogger) Errorf(format string, v ...any) LogBuilder
Errorf creates a new error event with the formatted message
func (*PrettyLogger) Fatal ¶
func (pl *PrettyLogger) Fatal(msg string) LogBuilder
Fatal creates a new fatal event with the given message
When sent, fatal events will cause a call to os.Exit(1)
func (*PrettyLogger) Fatalf ¶
func (pl *PrettyLogger) Fatalf(format string, v ...any) LogBuilder
Fatalf creates a new fatal event with the formatted message
When sent, fatal events will cause a call to os.Exit(1)
func (*PrettyLogger) Info ¶
func (pl *PrettyLogger) Info(msg string) LogBuilder
Info creates a new info event with the given message
func (*PrettyLogger) Infof ¶
func (pl *PrettyLogger) Infof(format string, v ...any) LogBuilder
Infof creates a new info event with the formatted message
func (*PrettyLogger) NoExit ¶
func (pl *PrettyLogger) NoExit()
NoExit prevents the logger from exiting on fatal events
func (*PrettyLogger) NoPanic ¶
func (pl *PrettyLogger) NoPanic()
NoPanic prevents the logger from panicking on panic events
func (*PrettyLogger) Panic ¶
func (pl *PrettyLogger) Panic(msg string) LogBuilder
Panic creates a new panic event with the given message
When sent, panic events will cause a panic
func (*PrettyLogger) Panicf ¶
func (pl *PrettyLogger) Panicf(format string, v ...any) LogBuilder
Panicf creates a new panic event with the formatted message
When sent, panic events will cause a panic
func (*PrettyLogger) SetLevel ¶
func (pl *PrettyLogger) SetLevel(l LogLevel)
SetLevel sets the log level of the logger
func (*PrettyLogger) Warn ¶
func (pl *PrettyLogger) Warn(msg string) LogBuilder
Warn creates a new warn event with the given message
func (*PrettyLogger) Warnf ¶
func (pl *PrettyLogger) Warnf(format string, v ...any) LogBuilder
Warnf creates a new warn event with the formatted message