refactor: framework modules log through diary components
- Each module logs through diary.For(<package>): cabana, lagoon, attach, cooler, postcard, beachcomber, lighthouse, centrifugo, flare, phrasebook, wristband, bouncer - App-published *slog.Logger overrides stay first; messages and attributes unchanged - sunscreen: InstallDefault documented as the compatibility entry point; diary wraps every channel - READMEs list diary as a dependency; logging docs: plugins use diary.For
This commit is contained in:
@@ -87,10 +87,15 @@ func Wrap(next slog.Handler) slog.Handler {
|
||||
}
|
||||
|
||||
// InstallDefault makes a redacting text handler writing to w the process
|
||||
// default logger (slog.SetDefault), so plugins that fall back to
|
||||
// slog.Default and the standard log package both log through it. It builds
|
||||
// a fresh slog.TextHandler instead of wrapping the existing default, whose
|
||||
// output goes through the log package that SetDefault redirects back here.
|
||||
// default logger (slog.SetDefault), so code that logs through slog.Default
|
||||
// and the standard log package both log through it. It builds a fresh
|
||||
// slog.TextHandler instead of wrapping the existing default, whose output
|
||||
// goes through the log package that SetDefault redirects back here.
|
||||
//
|
||||
// Generated applications no longer call it: they install the diary module,
|
||||
// which wraps every log channel with Wrap. InstallDefault stays as the
|
||||
// compatibility entry point for programs that install their own default
|
||||
// logger.
|
||||
func InstallDefault(w io.Writer) {
|
||||
slog.SetDefault(slog.New(Wrap(slog.NewTextHandler(w, nil))))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user