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:
Jakub Zych
2026-10-21 11:58:22 +02:00
parent 71b99317ad
commit 44291adcca
53 changed files with 185 additions and 130 deletions

View File

@@ -18,10 +18,15 @@ import (
"git.golem15.com/golem15/summercms/modules/backpack"
"git.golem15.com/golem15/summercms/modules/compass"
"git.golem15.com/golem15/summercms/modules/diary"
"git.golem15.com/golem15/summercms/modules/lagoon"
"gorm.io/gorm"
)
// moduleLog is lighthouse's logger: records carry component=lighthouse and follow
// log.components.lighthouse (diary).
var moduleLog = diary.For("lighthouse")
const (
// DefaultDriver is the driver used when realtime.driver is empty.
DefaultDriver = "null"
@@ -141,10 +146,11 @@ func (s *Service) Registry() *Registry {
return s.registry
}
// Logger returns the app logger the service and its driver log through.
// Logger returns the app logger the service and its driver log through: the
// logger the application published, else the lighthouse component logger.
func (s *Service) Logger() *slog.Logger {
if s == nil || s.log == nil {
return slog.Default()
return moduleLog
}
return s.log
}
@@ -198,5 +204,5 @@ func loggerFromApp(app *backpack.App) *slog.Logger {
return log
}
}
return slog.Default()
return moduleLog
}