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

@@ -183,7 +183,7 @@ ids, err := svc.Engine().SearchIDs(ctx, svc.IndexName(&models.Post{}), beachcomb
## Dependencies
- `backpack`, `compass` and `lagoon` (callback installation and `lagoon.AfterCommit`) from this repository.
- `backpack`, `compass`, `diary` (component logger `beachcomber` when the app publishes no logger) and `lagoon` (callback installation and `lagoon.AfterCommit`) from this repository.
- `gorm.io/gorm` (sync callbacks and reloads).
- The Typesense client is plain `net/http`; no Typesense SDK is used.

View File

@@ -16,10 +16,15 @@ import (
"sync"
"git.golem15.com/golem15/summercms/modules/backpack"
"git.golem15.com/golem15/summercms/modules/diary"
"git.golem15.com/golem15/summercms/modules/lagoon"
"gorm.io/gorm"
)
// moduleLog is beachcomber's logger: records carry component=beachcomber and follow
// log.components.beachcomber (diary).
var moduleLog = diary.For("beachcomber")
// DefaultDriver is the engine used when search.driver is empty.
const DefaultDriver = NullEngine
@@ -130,10 +135,11 @@ func (s *Service) IndexName(m Searchable) string {
return s.Prefix() + m.SearchableAs()
}
// Logger returns the app logger sync failures are logged through.
// Logger returns the app logger sync failures are logged through: the
// logger the application published, else the beachcomber component logger.
func (s *Service) Logger() *slog.Logger {
if s == nil || s.log == nil {
return slog.Default()
return moduleLog
}
return s.log
}
@@ -179,5 +185,5 @@ func loggerFromApp(app *backpack.App) *slog.Logger {
return log
}
}
return slog.Default()
return moduleLog
}