Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToSlogHandler
deprecated
added in
v0.2.8
ToSlogHandler wraps a ColdBrew log.Logger as an slog.Handler.
Deprecated: With the slog-native architecture, use log.GetHandler() directly as it already implements slog.Handler with context field injection. This function is kept for backward compatibility with custom Logger implementations.
func ToSlogLogger
deprecated
added in
v0.2.8
ToSlogLogger wraps a ColdBrew log.Logger as an *slog.Logger.
Deprecated: With the slog-native architecture, the global slog.Logger is already configured via log.SetDefault. Use slog.Default() or slog.New(log.GetHandler()) instead.
Example ¶
This example shows how to route slog calls through ColdBrew's logger. Third-party libraries using slog.Info() will flow through your ColdBrew logging pipeline (context fields, level overrides, interceptors).
package main
import (
"context"
"log/slog"
"github.com/go-coldbrew/log"
"github.com/go-coldbrew/log/wrap"
)
func main() {
// Set up slog's default to route through ColdBrew
sl := wrap.ToSlogLogger(log.GetLogger())
slog.SetDefault(sl)
// Now slog calls flow through ColdBrew's pipeline
ctx := context.Background()
slog.InfoContext(ctx, "request processed", "method", "GET", "status", 200)
}
Output:
Example (WithGroup) ¶
This example shows how to use slog's WithGroup and With methods through the ColdBrew bridge.
package main
import (
"context"
"github.com/go-coldbrew/log"
"github.com/go-coldbrew/log/wrap"
)
func main() {
sl := wrap.ToSlogLogger(log.GetLogger())
// Groups produce dot-separated keys (e.g., "request.method")
reqLogger := sl.WithGroup("request").With("trace_id", "abc-123")
ctx := context.Background()
reqLogger.InfoContext(ctx, "handled", "method", "POST", "path", "/api/orders")
}
Output:
Types ¶
This section is empty.