Documentation
¶
Overview ¶
Package log provides pluggable logging backends for the Gas ecosystem.
It implements the gas.Logger, gas.LogEvent, and gas.LoggerContext interfaces with three interchangeable backends:
- ZeroLogLogger — high-performance structured logging via zerolog.
- SlogLogger — standard library log/slog backend, zero external dependencies.
- [NoOpLogger] — discards all output; useful for tests and disabled logging.
All backends expose the same fluent API: call a level method (Info, Debug, etc.) to obtain a gas.LogEvent, chain field methods (Str, Int, Err, ...), and finalize with Send.
logger.Info("request handled").
Str("method", r.Method).
Int("status", code).
Duration("latency", elapsed).
Send()
Use With to create a sub-logger with persistent fields:
reqLogger := logger.With().Str("request_id", id).Logger()
Register a logger in the Gas DI container so services receive it automatically:
app := gas.NewApp( gas.WithService[gas.Logger](gaslog.NewZeroLogLogger(gaslog.WithZeroLogInstance(&zl)), gas.ServiceLifetimeScoped), )
Index ¶
- func NewShippingHandler(endpoint string, marshaler Marshaler, opts ...ShippingOption) (slog.Handler, io.Closer)
- type Handler
- type Marshaler
- type OTLPMarshaler
- type OTLPOption
- type Record
- type ShippingLogger
- type ShippingLoggerCtor
- type ShippingOption
- func WithBatchSize(n int) ShippingOption
- func WithErrorHandler(fn func(error)) ShippingOption
- func WithFlushInterval(d time.Duration) ShippingOption
- func WithHTTPClient(client *http.Client) ShippingOption
- func WithHeader(key, value string) ShippingOption
- func WithLevel(level slog.Leveler) ShippingOption
- func WithLocalHandler(h slog.Handler) ShippingOption
- func WithName(name string) ShippingOption
- func WithQueueSize(n int) ShippingOption
- func WithoutLocalHandler() ShippingOption
- type SlogLogEvent
- func (e *SlogLogEvent) Any(key string, value any) gas.LogEvent
- func (e *SlogLogEvent) Bool(key string, value bool) gas.LogEvent
- func (e *SlogLogEvent) Duration(key string, value time.Duration) gas.LogEvent
- func (e *SlogLogEvent) Err(key string, value error) gas.LogEvent
- func (e *SlogLogEvent) Float64(key string, value float64) gas.LogEvent
- func (e *SlogLogEvent) Int(key string, value int) gas.LogEvent
- func (e *SlogLogEvent) Int64(key string, value int64) gas.LogEvent
- func (e *SlogLogEvent) Send()
- func (e *SlogLogEvent) Str(key, value string) gas.LogEvent
- type SlogLogger
- func (l *SlogLogger) Debug(msg string) gas.LogEvent
- func (l *SlogLogger) Error(msg string) gas.LogEvent
- func (l *SlogLogger) Flush()
- func (l *SlogLogger) Info(msg string) gas.LogEvent
- func (l *SlogLogger) SetBaseFields() gas.MutableLoggerContext
- func (l *SlogLogger) Trace(msg string) gas.LogEvent
- func (l *SlogLogger) Warn(msg string) gas.LogEvent
- func (l *SlogLogger) With() gas.LoggerContext
- type SlogLoggerContext
- func (c *SlogLoggerContext) Any(key string, val any) gas.LoggerContext
- func (c *SlogLoggerContext) Bool(key string, val bool) gas.LoggerContext
- func (c *SlogLoggerContext) Duration(key string, val time.Duration) gas.LoggerContext
- func (c *SlogLoggerContext) Err(key string, val error) gas.LoggerContext
- func (c *SlogLoggerContext) Float64(key string, val float64) gas.LoggerContext
- func (c *SlogLoggerContext) Int(key string, val int) gas.LoggerContext
- func (c *SlogLoggerContext) Int64(key string, val int64) gas.LoggerContext
- func (c *SlogLoggerContext) Logger() gas.Logger
- func (c *SlogLoggerContext) Str(key, val string) gas.LoggerContext
- type SlogLoggerCtor
- type SlogLoggerOption
- type SlogMutableLoggerContext
- func (c *SlogMutableLoggerContext) Any(key string, val any) gas.MutableLoggerContext
- func (c *SlogMutableLoggerContext) Apply()
- func (c *SlogMutableLoggerContext) Bool(key string, val bool) gas.MutableLoggerContext
- func (c *SlogMutableLoggerContext) Duration(key string, val time.Duration) gas.MutableLoggerContext
- func (c *SlogMutableLoggerContext) Err(key string, val error) gas.MutableLoggerContext
- func (c *SlogMutableLoggerContext) Float64(key string, val float64) gas.MutableLoggerContext
- func (c *SlogMutableLoggerContext) Int(key string, val int) gas.MutableLoggerContext
- func (c *SlogMutableLoggerContext) Int64(key string, val int64) gas.MutableLoggerContext
- func (c *SlogMutableLoggerContext) Str(key, val string) gas.MutableLoggerContext
- type ZeroLogLogEvent
- func (e *ZeroLogLogEvent) Any(key string, value any) gas.LogEvent
- func (e *ZeroLogLogEvent) Bool(key string, value bool) gas.LogEvent
- func (e *ZeroLogLogEvent) Duration(key string, value time.Duration) gas.LogEvent
- func (e *ZeroLogLogEvent) Err(key string, value error) gas.LogEvent
- func (e *ZeroLogLogEvent) Float64(key string, value float64) gas.LogEvent
- func (e *ZeroLogLogEvent) Int(key string, value int) gas.LogEvent
- func (e *ZeroLogLogEvent) Int64(key string, value int64) gas.LogEvent
- func (e *ZeroLogLogEvent) Send()
- func (e *ZeroLogLogEvent) Str(key, value string) gas.LogEvent
- type ZeroLogLogger
- func (l *ZeroLogLogger) Debug(msg string) gas.LogEvent
- func (l *ZeroLogLogger) Error(msg string) gas.LogEvent
- func (l *ZeroLogLogger) Flush()
- func (l *ZeroLogLogger) Info(msg string) gas.LogEvent
- func (l *ZeroLogLogger) SetBaseFields() gas.MutableLoggerContext
- func (l *ZeroLogLogger) Trace(msg string) gas.LogEvent
- func (l *ZeroLogLogger) Warn(msg string) gas.LogEvent
- func (l *ZeroLogLogger) With() gas.LoggerContext
- type ZeroLogLoggerContext
- func (c *ZeroLogLoggerContext) Any(key string, val any) gas.LoggerContext
- func (c *ZeroLogLoggerContext) Bool(key string, val bool) gas.LoggerContext
- func (c *ZeroLogLoggerContext) Duration(key string, val time.Duration) gas.LoggerContext
- func (c *ZeroLogLoggerContext) Err(key string, val error) gas.LoggerContext
- func (c *ZeroLogLoggerContext) Float64(key string, val float64) gas.LoggerContext
- func (c *ZeroLogLoggerContext) Int(key string, val int) gas.LoggerContext
- func (c *ZeroLogLoggerContext) Int64(key string, val int64) gas.LoggerContext
- func (c *ZeroLogLoggerContext) Logger() gas.Logger
- func (c *ZeroLogLoggerContext) Str(key, val string) gas.LoggerContext
- type ZeroLogLoggerCtor
- type ZeroLogLoggerOption
- type ZeroLogMutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Any(key string, val any) gas.MutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Apply()
- func (c *ZeroLogMutableLoggerContext) Bool(key string, val bool) gas.MutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Duration(key string, val time.Duration) gas.MutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Err(key string, val error) gas.MutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Float64(key string, val float64) gas.MutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Int(key string, val int) gas.MutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Int64(key string, val int64) gas.MutableLoggerContext
- func (c *ZeroLogMutableLoggerContext) Str(key, val string) gas.MutableLoggerContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewShippingHandler ¶
func NewShippingHandler(endpoint string, marshaler Marshaler, opts ...ShippingOption) (slog.Handler, io.Closer)
NewShippingHandler builds an slog.Handler that writes locally and ships every record over HTTP, together with an io.Closer that drains and stops delivery. Use it to add shipping to an existing slog setup — for example slog.SetDefault(slog.New(h)) — without adopting the gas.Logger wrapper.
The same options as NewShippingLogger apply. Call Close (typically on shutdown) to flush buffered records and stop the delivery goroutine.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is an slog.Handler that captures records and hands them to a batching HTTP sender. Construct it via NewShippingLogger; it is exported only so it can be composed into custom handler chains.
type Marshaler ¶
type Marshaler interface {
// Marshal encodes the batch into one request body.
Marshal(records []Record) ([]byte, error)
// ContentType is the value sent in the Content-Type header.
ContentType() string
}
Marshaler encodes a batch of records into a single HTTP request body. The wire shape (OTLP, ECS, a custom schema, ...) is entirely the marshaler's concern, which is what keeps the transport reusable across backends.
type OTLPMarshaler ¶
type OTLPMarshaler struct {
// contains filtered or unexported fields
}
OTLPMarshaler encodes records as OpenTelemetry OTLP/HTTP logs JSON: the resourceLogs -> scopeLogs -> logRecords shape an OTLP exporter would send.
func NewOTLPMarshaler ¶
func NewOTLPMarshaler(opts ...OTLPOption) *OTLPMarshaler
NewOTLPMarshaler builds an OTLP/HTTP JSON marshaler.
func (*OTLPMarshaler) ContentType ¶
func (m *OTLPMarshaler) ContentType() string
ContentType returns the OTLP/HTTP JSON content type.
type OTLPOption ¶
type OTLPOption func(*OTLPMarshaler)
OTLPOption configures an OTLPMarshaler.
func WithResourceAttribute ¶
func WithResourceAttribute(key, value string) OTLPOption
WithResourceAttribute adds an arbitrary resource attribute (host.name, deployment.environment, ...).
func WithScopeName ¶
func WithScopeName(name string) OTLPOption
WithScopeName sets the instrumentation scope name reported for each batch.
func WithServiceName ¶
func WithServiceName(name string) OTLPOption
WithServiceName sets the resource service.name attribute. It also seeds the instrumentation scope name when one has not been set explicitly.
func WithServiceVersion ¶
func WithServiceVersion(version string) OTLPOption
WithServiceVersion sets the resource service.version attribute.
type Record ¶
Record is a backend-neutral log record handed to a Marshaler. It carries the level, timestamp, message, and the fully-qualified attributes captured from an slog event.
type ShippingLogger ¶
type ShippingLogger struct {
*SlogLogger
// contains filtered or unexported fields
}
ShippingLogger is a gas.Logger that writes locally and ships every record to an HTTP endpoint via a pluggable Marshaler. It reuses SlogLogger for the fluent API and adds batching HTTP delivery underneath.
It implements gas.Service: when registered in the DI container, Close is called at shutdown and drains any buffered records.
func (*ShippingLogger) Close ¶
func (l *ShippingLogger) Close() error
Close drains buffered records and stops the delivery goroutine. It is idempotent (implements gas.Service).
func (*ShippingLogger) Flush ¶
func (l *ShippingLogger) Flush()
Flush posts any buffered records and blocks until they have been sent, overriding the no-op inherited from SlogLogger.
func (*ShippingLogger) Init ¶
func (l *ShippingLogger) Init() error
Init is a no-op; the delivery goroutine starts at construction so the logger works with or without the DI container (implements gas.Service).
func (*ShippingLogger) Name ¶
func (l *ShippingLogger) Name() string
Name returns the service name (implements gas.Service).
type ShippingLoggerCtor ¶
type ShippingLoggerCtor func() *ShippingLogger
ShippingLoggerCtor constructs a ShippingLogger; it satisfies the Gas DI container's constructor shape.
func NewShippingLogger ¶
func NewShippingLogger(endpoint string, marshaler Marshaler, opts ...ShippingOption) ShippingLoggerCtor
NewShippingLogger returns a constructor for a logger that ships records to endpoint using marshaler. By default it also logs JSON to stderr; use WithoutLocalHandler or WithLocalHandler to change that.
type ShippingOption ¶
type ShippingOption func(*shippingConfig)
ShippingOption configures a shipping logger built by NewShippingLogger.
func WithBatchSize ¶
func WithBatchSize(n int) ShippingOption
WithBatchSize sets how many records accumulate before a batch is sent.
func WithErrorHandler ¶
func WithErrorHandler(fn func(error)) ShippingOption
WithErrorHandler registers a callback invoked on delivery failures (marshal, transport, or non-2xx responses). Delivery errors never reach the log call.
func WithFlushInterval ¶
func WithFlushInterval(d time.Duration) ShippingOption
WithFlushInterval sets the maximum time a record waits before delivery.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ShippingOption
WithHTTPClient overrides the HTTP client used for delivery.
func WithHeader ¶
func WithHeader(key, value string) ShippingOption
WithHeader sets a request header sent on every batch (e.g. an API key).
func WithLevel ¶
func WithLevel(level slog.Leveler) ShippingOption
WithLevel sets the minimum level shipped remotely.
func WithLocalHandler ¶
func WithLocalHandler(h slog.Handler) ShippingOption
WithLocalHandler sets the handler that also receives every record locally (for stdout/file logging alongside shipping).
func WithName ¶
func WithName(name string) ShippingOption
WithName sets the gas.Service name reported by the logger.
func WithQueueSize ¶
func WithQueueSize(n int) ShippingOption
WithQueueSize sets the buffered-record capacity; records are dropped when the queue is full, so the logging path never blocks.
func WithoutLocalHandler ¶
func WithoutLocalHandler() ShippingOption
WithoutLocalHandler disables local logging, shipping records only.
type SlogLogEvent ¶
type SlogLogEvent struct {
// contains filtered or unexported fields
}
SlogLogEvent collects structured fields and emits them as a single log record via slog.Logger.LogAttrs when Send is called. Implements gas.LogEvent.
func (*SlogLogEvent) Any ¶
func (e *SlogLogEvent) Any(key string, value any) gas.LogEvent
Any adds a key-value pair with a value of any type to the log event's attributes and returns the modified log event.
func (*SlogLogEvent) Bool ¶
func (e *SlogLogEvent) Bool(key string, value bool) gas.LogEvent
Bool adds a boolean attribute with the specified key and value to the log event and returns the updated log event.
func (*SlogLogEvent) Duration ¶
Duration adds a time.Duration attribute to the log event with the specified key and value.
func (*SlogLogEvent) Err ¶
func (e *SlogLogEvent) Err(key string, value error) gas.LogEvent
Err adds an error attribute to the log event with the specified key and error value and returns the updated log event.
func (*SlogLogEvent) Float64 ¶
func (e *SlogLogEvent) Float64(key string, value float64) gas.LogEvent
Float64 adds a float64 attribute to the log event with the given key and value.
func (*SlogLogEvent) Int ¶
func (e *SlogLogEvent) Int(key string, value int) gas.LogEvent
Int adds an integer-typed attribute with the specified key and value to the log event and returns the updated event.
func (*SlogLogEvent) Int64 ¶
func (e *SlogLogEvent) Int64(key string, value int64) gas.LogEvent
Int64 adds a key-value pair, where the value is of int64 type, to the log event's attributes.
func (*SlogLogEvent) Send ¶
func (e *SlogLogEvent) Send()
Send emits the constructed log event with its attributes to the logger.
type SlogLogger ¶
type SlogLogger struct {
// contains filtered or unexported fields
}
SlogLogger adapts a standard library slog.Logger to the gas.Logger interface. It requires no external dependencies beyond the Go standard library. Since slog has no Trace level, both Trace and Debug map to slog.LevelDebug.
func (*SlogLogger) Debug ¶
func (l *SlogLogger) Debug(msg string) gas.LogEvent
Debug creates a new log event with debug level and the specified message.
func (*SlogLogger) Error ¶
func (l *SlogLogger) Error(msg string) gas.LogEvent
Error creates a log event with error level and the specified message.
func (*SlogLogger) Flush ¶
func (l *SlogLogger) Flush()
Flush ensures that all buffered log entries are written to their destination immediately.
func (*SlogLogger) Info ¶
func (l *SlogLogger) Info(msg string) gas.LogEvent
Info creates an info-level log event with the specified message and initializes its attributes list.
func (*SlogLogger) SetBaseFields ¶
func (l *SlogLogger) SetBaseFields() gas.MutableLoggerContext
SetBaseFields initializes and returns a mutable logger context for adding attributes to the originating logger.
func (*SlogLogger) Trace ¶
func (l *SlogLogger) Trace(msg string) gas.LogEvent
Trace creates a log event with a debug level and the provided message, enabling attribute chaining before sending.
func (*SlogLogger) Warn ¶
func (l *SlogLogger) Warn(msg string) gas.LogEvent
Warn creates a log event with warn level and a specified message. It returns the constructed log event.
func (*SlogLogger) With ¶
func (l *SlogLogger) With() gas.LoggerContext
With creates and returns a new SlogLoggerContext for structured logging with accumulated attributes.
type SlogLoggerContext ¶
type SlogLoggerContext struct {
// contains filtered or unexported fields
}
SlogLoggerContext accumulates structured fields and produces a sub-logger with those fields baked in when Logger is called. Implements gas.LoggerContext.
func (*SlogLoggerContext) Any ¶
func (c *SlogLoggerContext) Any(key string, val any) gas.LoggerContext
Any adds a key-value pair to the context using a value of any type and returns the updated LoggerContext.
func (*SlogLoggerContext) Bool ¶
func (c *SlogLoggerContext) Bool(key string, val bool) gas.LoggerContext
Bool adds a boolean key-value pair to the logger context and returns the updated logger context.
func (*SlogLoggerContext) Duration ¶
func (c *SlogLoggerContext) Duration(key string, val time.Duration) gas.LoggerContext
Duration adds a time duration attribute to the logger context with the specified key and value.
func (*SlogLoggerContext) Err ¶
func (c *SlogLoggerContext) Err(key string, val error) gas.LoggerContext
Err adds an error value to the logger context with the specified key and returns the updated logger context.
func (*SlogLoggerContext) Float64 ¶
func (c *SlogLoggerContext) Float64(key string, val float64) gas.LoggerContext
Float64 adds a float64 key-value pair to the logger context and returns the updated context.
func (*SlogLoggerContext) Int ¶
func (c *SlogLoggerContext) Int(key string, val int) gas.LoggerContext
Int adds an integer attribute with the specified key and value to the logger context and returns the updated context.
func (*SlogLoggerContext) Int64 ¶
func (c *SlogLoggerContext) Int64(key string, val int64) gas.LoggerContext
Int64 appends a key-value pair where the value is an int64 to the logger context and returns the updated context.
func (*SlogLoggerContext) Logger ¶
func (c *SlogLoggerContext) Logger() gas.Logger
Logger creates a new logger instance with accumulated attributes and returns it as a gas.Logger implementation.
func (*SlogLoggerContext) Str ¶
func (c *SlogLoggerContext) Str(key, val string) gas.LoggerContext
Str adds a string key-value pair to the logger context and returns the updated context.
type SlogLoggerCtor ¶
type SlogLoggerCtor func() *SlogLogger
SlogLoggerCtor defines a constructor function that returns an implementation of the gas.Logger interface.
func NewSlogLogger ¶
func NewSlogLogger(opts ...SlogLoggerOption) SlogLoggerCtor
NewSlogLogger returns a SlogLoggerCtor that constructs a SlogLogger with the provided SlogLoggerOption values.
type SlogLoggerOption ¶
type SlogLoggerOption func(*SlogLogger)
SlogLoggerOption is a functional option type for configuring an instance of SlogLogger.
func WithEventInitialCapacity ¶
func WithEventInitialCapacity(capacity int) SlogLoggerOption
WithEventInitialCapacity sets the initial capacity for event attributes in a SlogLogger instance.
func WithSlogInstance ¶
func WithSlogInstance(logger *slog.Logger) SlogLoggerOption
WithSlogInstance sets the provided slog.Logger instance to the SlogLogger.
type SlogMutableLoggerContext ¶
type SlogMutableLoggerContext struct {
// contains filtered or unexported fields
}
SlogMutableLoggerContext accumulates fields and on Apply mutates the originating SlogLogger in-place. Implements gas.MutableLoggerContext.
func (*SlogMutableLoggerContext) Any ¶
func (c *SlogMutableLoggerContext) Any(key string, val any) gas.MutableLoggerContext
Any adds a key-value pair with a value of any type to the logger context and returns the updated context.
func (*SlogMutableLoggerContext) Apply ¶
func (c *SlogMutableLoggerContext) Apply()
Apply updates the originating logger by appending the accumulated attributes in the current context.
func (*SlogMutableLoggerContext) Bool ¶
func (c *SlogMutableLoggerContext) Bool(key string, val bool) gas.MutableLoggerContext
Bool adds a boolean attribute with the given key and value to the logger context and returns the updated context.
func (*SlogMutableLoggerContext) Duration ¶
func (c *SlogMutableLoggerContext) Duration(key string, val time.Duration) gas.MutableLoggerContext
Duration adds a duration attribute to the context with the specified key and value, returning the updated context.
func (*SlogMutableLoggerContext) Err ¶
func (c *SlogMutableLoggerContext) Err(key string, val error) gas.MutableLoggerContext
Err adds an error value to the logger context with the specified key and returns the updated context.
func (*SlogMutableLoggerContext) Float64 ¶
func (c *SlogMutableLoggerContext) Float64(key string, val float64) gas.MutableLoggerContext
Float64 adds a float64 attribute with the given key and value to the logging context and returns the updated context.
func (*SlogMutableLoggerContext) Int ¶
func (c *SlogMutableLoggerContext) Int(key string, val int) gas.MutableLoggerContext
Int adds an integer attribute with the given key and value to the logger context and returns the updated context.
func (*SlogMutableLoggerContext) Int64 ¶
func (c *SlogMutableLoggerContext) Int64(key string, val int64) gas.MutableLoggerContext
Int64 appends an int64 attribute with the specified key and value to the logger context and returns the updated context.
func (*SlogMutableLoggerContext) Str ¶
func (c *SlogMutableLoggerContext) Str(key, val string) gas.MutableLoggerContext
Str adds a string attribute to the logger context with the specified key and value and returns the updated context.
type ZeroLogLogEvent ¶
type ZeroLogLogEvent struct {
// contains filtered or unexported fields
}
ZeroLogLogEvent wraps a zerolog.Event to implement gas.LogEvent. Fields are chained fluently and the event is emitted when Send is called.
func (*ZeroLogLogEvent) Any ¶
func (e *ZeroLogLogEvent) Any(key string, value any) gas.LogEvent
Any adds a key-value pair to the log event, where the value can be of any data type, and returns the updated event.
func (*ZeroLogLogEvent) Bool ¶
func (e *ZeroLogLogEvent) Bool(key string, value bool) gas.LogEvent
Bool adds a boolean field to the log event with the specified key and value.
func (*ZeroLogLogEvent) Duration ¶
Duration adds a key-value pair where the value is a time.Duration, returning the updated log event instance.
func (*ZeroLogLogEvent) Err ¶
func (e *ZeroLogLogEvent) Err(key string, value error) gas.LogEvent
Err adds an error key-value pair to the log event and returns the updated log event.
func (*ZeroLogLogEvent) Float64 ¶
func (e *ZeroLogLogEvent) Float64(key string, value float64) gas.LogEvent
Float64 adds a float64 key-value pair to the log event and returns the updated log event.
func (*ZeroLogLogEvent) Int ¶
func (e *ZeroLogLogEvent) Int(key string, value int) gas.LogEvent
Int adds an integer field to the log event with the specified key and value and returns the updated log event.
func (*ZeroLogLogEvent) Int64 ¶
func (e *ZeroLogLogEvent) Int64(key string, value int64) gas.LogEvent
Int64 adds an int64 key-value pair to the log event and returns the updated event for method chaining.
func (*ZeroLogLogEvent) Send ¶
func (e *ZeroLogLogEvent) Send()
Send emits the configured log event with the current message and attributes.
type ZeroLogLogger ¶
type ZeroLogLogger struct {
// contains filtered or unexported fields
}
ZeroLogLogger adapts a zerolog.Logger to the gas.Logger interface. It provides high-performance structured JSON logging with full support for all gas log levels including Trace.
func (*ZeroLogLogger) Debug ¶
func (l *ZeroLogLogger) Debug(msg string) gas.LogEvent
Debug logs a message at the debug level and returns a LogEvent for adding structured fields before emitting.
func (*ZeroLogLogger) Error ¶
func (l *ZeroLogLogger) Error(msg string) gas.LogEvent
Error logs a message at the error level and returns a log event for further customization.
func (*ZeroLogLogger) Flush ¶
func (l *ZeroLogLogger) Flush()
Flush ensures that all buffered log entries are written to their destination immediately.
func (*ZeroLogLogger) Info ¶
func (l *ZeroLogLogger) Info(msg string) gas.LogEvent
Info logs an informational message and returns a LogEvent for adding structured fields before emitting.
func (*ZeroLogLogger) SetBaseFields ¶
func (l *ZeroLogLogger) SetBaseFields() gas.MutableLoggerContext
SetBaseFields initializes a mutable logger context with the current logger and returns it for field accumulation.
func (*ZeroLogLogger) Trace ¶
func (l *ZeroLogLogger) Trace(msg string) gas.LogEvent
Trace creates a trace-level log event with the provided message and returns it for further field chaining.
func (*ZeroLogLogger) Warn ¶
func (l *ZeroLogLogger) Warn(msg string) gas.LogEvent
Warn logs a warning-level message and returns a log event for attaching additional fields before sending.
func (*ZeroLogLogger) With ¶
func (l *ZeroLogLogger) With() gas.LoggerContext
With creates and returns a new LoggerContext for structured logging with additional fields.
type ZeroLogLoggerContext ¶
type ZeroLogLoggerContext struct {
// contains filtered or unexported fields
}
ZeroLogLoggerContext wraps a zerolog.Context to implement gas.LoggerContext. Fields added via chained methods are baked into the sub-logger returned by Logger.
func (*ZeroLogLoggerContext) Any ¶
func (c *ZeroLogLoggerContext) Any(key string, val any) gas.LoggerContext
Any adds a field with the given key and a value of any type to the logging context.
func (*ZeroLogLoggerContext) Bool ¶
func (c *ZeroLogLoggerContext) Bool(key string, val bool) gas.LoggerContext
Bool adds a boolean field with the specified key and value to the logging context and returns the updated context.
func (*ZeroLogLoggerContext) Duration ¶
func (c *ZeroLogLoggerContext) Duration(key string, val time.Duration) gas.LoggerContext
Duration adds a time.Duration field to the logger context with the specified key and value.
func (*ZeroLogLoggerContext) Err ¶
func (c *ZeroLogLoggerContext) Err(key string, val error) gas.LoggerContext
Err adds an error field to the logging context with the specified key and value.
func (*ZeroLogLoggerContext) Float64 ¶
func (c *ZeroLogLoggerContext) Float64(key string, val float64) gas.LoggerContext
Float64 adds a float64 value with the specified key to the logger context and returns the updated context.
func (*ZeroLogLoggerContext) Int ¶
func (c *ZeroLogLoggerContext) Int(key string, val int) gas.LoggerContext
Int adds an integer field with the given key and value to the logging context and returns the updated context.
func (*ZeroLogLoggerContext) Int64 ¶
func (c *ZeroLogLoggerContext) Int64(key string, val int64) gas.LoggerContext
Int64 adds an int64 key-value pair to the logging context and returns the updated LoggerContext.
func (*ZeroLogLoggerContext) Logger ¶
func (c *ZeroLogLoggerContext) Logger() gas.Logger
Logger creates a new structured logger instance with all chained fields applied.
func (*ZeroLogLoggerContext) Str ¶
func (c *ZeroLogLoggerContext) Str(key, val string) gas.LoggerContext
Str adds a string key-value pair to the logger context and returns the updated LoggerContext.
type ZeroLogLoggerCtor ¶
type ZeroLogLoggerCtor func() *ZeroLogLogger
ZeroLogLoggerCtor is a function type that constructs and returns a gas.Logger instance.
func NewZeroLogLogger ¶
func NewZeroLogLogger(opts ...ZeroLogLoggerOption) ZeroLogLoggerCtor
NewZeroLogLogger creates a new ZeroLogLoggerCtor with optional configuration applied via ZeroLogLoggerOption functions.
type ZeroLogLoggerOption ¶
type ZeroLogLoggerOption func(*ZeroLogLogger)
ZeroLogLoggerOption represents a functional option for configuring a ZeroLogLogger instance.
func WithZeroLogInstance ¶
func WithZeroLogInstance(logger *zerolog.Logger) ZeroLogLoggerOption
WithZeroLogInstance sets the underlying zerolog.Logger instance for the ZeroLogLogger.
type ZeroLogMutableLoggerContext ¶
type ZeroLogMutableLoggerContext struct {
// contains filtered or unexported fields
}
ZeroLogMutableLoggerContext accumulates fields and on Apply mutates the originating ZeroLogLogger in-place. Implements gas.MutableLoggerContext.
func (*ZeroLogMutableLoggerContext) Any ¶
func (c *ZeroLogMutableLoggerContext) Any(key string, val any) gas.MutableLoggerContext
Any adds a key-value pair to the logger context where the value can be of any type and returns the updated context.
func (*ZeroLogMutableLoggerContext) Apply ¶
func (c *ZeroLogMutableLoggerContext) Apply()
Apply writes the accumulated context fields to the originating ZeroLogLogger by mutating it in place.
func (*ZeroLogMutableLoggerContext) Bool ¶
func (c *ZeroLogMutableLoggerContext) Bool(key string, val bool) gas.MutableLoggerContext
Bool adds a boolean field with the specified key and value to the logging context and returns the updated context.
func (*ZeroLogMutableLoggerContext) Duration ¶
func (c *ZeroLogMutableLoggerContext) Duration(key string, val time.Duration) gas.MutableLoggerContext
Duration adds a duration field with the specified key and value to the logging context and returns the updated context.
func (*ZeroLogMutableLoggerContext) Err ¶
func (c *ZeroLogMutableLoggerContext) Err(key string, val error) gas.MutableLoggerContext
Err adds an error field to the logging context with the specified key and value, and returns the updated context.
func (*ZeroLogMutableLoggerContext) Float64 ¶
func (c *ZeroLogMutableLoggerContext) Float64(key string, val float64) gas.MutableLoggerContext
Float64 adds a float64 field with the specified key and value to the logger context and returns the updated context.
func (*ZeroLogMutableLoggerContext) Int ¶
func (c *ZeroLogMutableLoggerContext) Int(key string, val int) gas.MutableLoggerContext
Int adds an integer field with the specified key and value to the logger context and returns the updated context.
func (*ZeroLogMutableLoggerContext) Int64 ¶
func (c *ZeroLogMutableLoggerContext) Int64(key string, val int64) gas.MutableLoggerContext
Int64 adds a key-value pair with an int64 value to the logger context and returns the updated MutableLoggerContext.
func (*ZeroLogMutableLoggerContext) Str ¶
func (c *ZeroLogMutableLoggerContext) Str(key, val string) gas.MutableLoggerContext
Str adds a string field with the specified key and value to the logger context and returns the updated context.