Documentation
¶
Index ¶
- func Init(ctx context.Context, cfg Config) error
- func Use(log *Logger)
- func With() zerolog.Context
- type Config
- type Event
- func (e *Event) AnErr(key string, err error) *Event
- func (e *Event) Any(key string, val interface{}) *Event
- func (e *Event) Array(key string, arr zerolog.LogArrayMarshaler) *Event
- func (e *Event) Bool(key string, val bool) *Event
- func (e *Event) Bools(key string, vals []bool) *Event
- func (e *Event) Bytes(key string, val []byte) *Event
- func (e *Event) Caller(skip ...int) *Event
- func (e *Event) Ctx(ctx context.Context) *Event
- func (e *Event) Dict(key string, dict *zerolog.Event) *Event
- func (e *Event) Discard() *Event
- func (e *Event) Dur(key string, val time.Duration) *Event
- func (e *Event) Durs(key string, vals []time.Duration) *Event
- func (e *Event) EmbedObject(obj zerolog.LogObjectMarshaler) *Event
- func (e *Event) Enabled() bool
- func (e *Event) Err(err error) *Event
- func (e *Event) Errs(key string, errs []error) *Event
- func (e *Event) Float32(key string, val float32) *Event
- func (e *Event) Float64(key string, val float64) *Event
- func (e *Event) Floats32(key string, vals []float32) *Event
- func (e *Event) Floats64(key string, vals []float64) *Event
- func (e *Event) Hex(key string, val []byte) *Event
- func (e *Event) Int(key string, val int) *Event
- func (e *Event) Int16(key string, val int16) *Event
- func (e *Event) Int32(key string, val int32) *Event
- func (e *Event) Int64(key string, val int64) *Event
- func (e *Event) Int8(key string, val int8) *Event
- func (e *Event) Interface(key string, val interface{}) *Event
- func (e *Event) Ints(key string, vals []int) *Event
- func (e *Event) Object(key string, obj zerolog.LogObjectMarshaler) *Event
- func (e *Event) RawJSON(key string, b []byte) *Event
- func (e *Event) Stack() *Event
- func (e *Event) Str(key, val string) *Event
- func (e *Event) Strs(key string, vals []string) *Event
- func (e *Event) Time(key string, val time.Time) *Event
- func (e *Event) TimeDiff(key string, t time.Time, start time.Time) *Event
- func (e *Event) Times(key string, vals []time.Time) *Event
- func (e *Event) Timestamp() *Event
- func (e *Event) Uint(key string, val uint) *Event
- func (e *Event) Uint16(key string, val uint16) *Event
- func (e *Event) Uint32(key string, val uint32) *Event
- func (e *Event) Uint64(key string, val uint64) *Event
- func (e *Event) Uint8(key string, val uint8) *Event
- func (e *Event) Uints(key string, vals []uint) *Event
- type FileConfig
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug() *Event
- func (l *Logger) Err(err error) *Event
- func (l *Logger) Error() *Event
- func (l *Logger) Fatal() *Event
- func (l *Logger) Info() *Event
- func (l *Logger) Warn() *Event
- func (l *Logger) With() zerolog.Context
- func (l *Logger) WithLevel(level zerolog.Level) *Event
- type OTLPConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶ added in v0.0.3
Init constructs a logger using New and makes it globally available via package-level helpers.
Types ¶
type Config ¶
type Config struct {
Enabled bool
Level string `default:"info"`
Environment string `default:"development"`
ServiceName string `default:"unknown-service"`
Console bool `default:"true"`
Writers []io.Writer
OTLP OTLPConfig
File FileConfig
UseGlobal bool
}
Config drives logger construction without importing the logging implementation details.
func (Config) ApplyDefaults ¶ added in v0.0.3
ApplyDefaults returns a copy of the config with default values populated.
type Event ¶ added in v0.0.5
Event wraps zerolog.Event to intercept Err() for stack trace injection.
func Debug ¶ added in v0.0.3
func Debug() *Event
Debug opens a debug event through the global logger.
func Error ¶ added in v0.0.3
func Error() *Event
Error opens an error event through the global logger.
func Fatal ¶ added in v0.0.3
func Fatal() *Event
Fatal opens a fatal event through the global logger.
func WithLevel ¶ added in v0.0.5
WithLevel opens an event at the specified level through the global logger.
func (*Event) Array ¶ added in v0.0.5
func (e *Event) Array(key string, arr zerolog.LogArrayMarshaler) *Event
Array adds an array field.
func (*Event) EmbedObject ¶ added in v0.0.5
func (e *Event) EmbedObject(obj zerolog.LogObjectMarshaler) *Event
EmbedObject embeds an object.
func (*Event) Object ¶ added in v0.0.5
func (e *Event) Object(key string, obj zerolog.LogObjectMarshaler) *Event
Object marshals an object.
func (*Event) TimeDiff ¶ added in v0.0.5
TimeDiff adds a duration field representing the difference between two times.
type FileConfig ¶ added in v0.0.3
type FileConfig struct {
Enabled bool
Directory string `validate:"required_if=Enabled true"`
Buffer int `default:"1024" validate:"omitempty,gt=0"`
}
FileConfig controls optional file-based logging.
type Logger ¶
Logger wraps zerolog.Logger with trace metadata injection and resource management.
func Global ¶ added in v0.0.3
func Global() *Logger
Global returns the current global logger reference. Panics if logger has not been initialized via Init() or Use().
func (*Logger) Close ¶ added in v0.0.5
Close shuts down the logger and releases any resources including file handles and background goroutines.
func (*Logger) Err ¶ added in v0.0.5
Err opens an error level event with the given error wrapped with stack trace.
type OTLPConfig ¶ added in v0.0.3
type OTLPConfig struct {
Enabled bool
Endpoint string `validate:"required_if=Enabled true"`
Insecure bool
Headers map[string]string
Timeout time.Duration `default:"5s" validate:"omitempty,gt=0"`
Exporter string `default:"http" validate:"oneof=http grpc"`
Credentials auth.Credentials
Async bool
UseSpool bool
QueueDir string
}
OTLPConfig captures OTLP export settings for log delivery. Endpoint accepts a base URL (host[:port] with optional path). When a scheme is provided, TLS is inferred automatically (http => insecure, https => secure). Without a scheme, the Insecure flag determines whether TLS is disabled.