Documentation
¶
Index ¶
- type ContextFieldsProviderFunc
- type Fields
- type LogSinkFunc
- type Logger
- type NoopLogger
- func (n NoopLogger) Debug(ctx context.Context, message string, fields ...Fields)
- func (n NoopLogger) Error(ctx context.Context, message string, err error, fields ...Fields)
- func (n NoopLogger) ErrorNoStack(ctx context.Context, message string, err error, fields ...Fields)
- func (n NoopLogger) Info(ctx context.Context, message string, fields ...Fields)
- func (n NoopLogger) SetContextFieldsProvider(provider ContextFieldsProviderFunc)
- func (n NoopLogger) SetLogSink(sink LogSinkFunc)
- func (n NoopLogger) Sync() error
- func (n NoopLogger) Warn(ctx context.Context, message string, fields ...Fields)
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextFieldsProviderFunc ¶
ContextFieldsProviderFunc extracts context-bound fields (e.g. request/trace IDs) for every log and sink export.
type Fields ¶
Fields is a logger-agnostic key/value hashmap.
func CloneFields ¶
CloneFields returns a shallow copy of fields. Nested values (maps, slices, pointers) are shared.
func FromPairs ¶
FromPairs creates fields from key/value pairs. If pairs length is odd, the last key is ignored.
func MergeFields ¶
func OptionalFields ¶
OptionalFields returns the first variadic Fields argument, or nil if none provided.
type LogSinkFunc ¶
LogSinkFunc is an optional secondary sink for structured logs. The primary sink can stay terminal/stdout; this sink can export to any backend without coupling the logger API.
type Logger ¶
type Logger interface {
Debug(ctx context.Context, message string, fields ...Fields)
Info(ctx context.Context, message string, fields ...Fields)
Warn(ctx context.Context, message string, fields ...Fields)
Error(ctx context.Context, message string, err error, fields ...Fields)
// ErrorNoStack logs at error level without stack trace for expected failures.
ErrorNoStack(ctx context.Context, message string, err error, fields ...Fields)
// SetLogSink sets a secondary log sink. Must be called during startup before concurrent logging begins.
SetLogSink(sink LogSinkFunc)
// SetContextFieldsProvider sets the provider for context-bound fields. Must be called during startup before concurrent logging begins.
SetContextFieldsProvider(provider ContextFieldsProviderFunc)
Sync() error
}
Logger defines the project logging contract. Context is included in every call so tracing metadata can be attached later without changing call sites.
type NoopLogger ¶ added in v0.5.0
type NoopLogger struct{}
NoopLogger is a no-op implementation of Logger.
func (NoopLogger) Debug ¶ added in v0.5.0
func (n NoopLogger) Debug(ctx context.Context, message string, fields ...Fields)
func (NoopLogger) ErrorNoStack ¶ added in v0.5.0
func (NoopLogger) Info ¶ added in v0.5.0
func (n NoopLogger) Info(ctx context.Context, message string, fields ...Fields)
func (NoopLogger) SetContextFieldsProvider ¶ added in v0.5.0
func (n NoopLogger) SetContextFieldsProvider(provider ContextFieldsProviderFunc)
func (NoopLogger) SetLogSink ¶ added in v0.5.0
func (n NoopLogger) SetLogSink(sink LogSinkFunc)
func (NoopLogger) Sync ¶ added in v0.5.0
func (n NoopLogger) Sync() error