Documentation
¶
Index ¶
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)
// 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.