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:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"slices"
|
||||
@@ -154,7 +153,7 @@ func ExecuteList(ctx context.Context, db *gorm.DB, cc *CompiledController, in Li
|
||||
}
|
||||
if hook, ok := cc.Controller.(pact.ListExtendRecords); ok && hook != nil && len(records) > 0 {
|
||||
if err := hook.ListExtendRecords(ctx, db.WithContext(ctx), records); err != nil {
|
||||
slog.Error("cabana: list extend records failed", "controller", controllerID(cc), "error", err)
|
||||
moduleLog.Error("cabana: list extend records failed", "controller", controllerID(cc), "error", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -195,11 +194,11 @@ func listRowStates(ctx context.Context, db *gorm.DB, cc *CompiledController, rec
|
||||
}
|
||||
result, err := hook.ListRowStates(ctx, db.WithContext(ctx), records)
|
||||
if err != nil {
|
||||
slog.Error("cabana: list row states failed", "controller", controllerID(cc), "error", err)
|
||||
moduleLog.Error("cabana: list row states failed", "controller", controllerID(cc), "error", err)
|
||||
return nil, err
|
||||
}
|
||||
if len(result) != len(records) {
|
||||
slog.Error("cabana: list row states are not aligned with the page", "controller", controllerID(cc), "records", len(records), "states", len(result))
|
||||
moduleLog.Error("cabana: list row states are not aligned with the page", "controller", controllerID(cc), "records", len(records), "states", len(result))
|
||||
return nil, fmt.Errorf("cabana: controller %s returned %d row states for %d records", controllerID(cc), len(result), len(records))
|
||||
}
|
||||
var out map[string][]string
|
||||
@@ -210,7 +209,7 @@ func listRowStates(ctx context.Context, db *gorm.DB, cc *CompiledController, rec
|
||||
has := map[pact.RowState]bool{}
|
||||
for _, state := range states {
|
||||
if !slices.Contains(rowStateOrder, state) {
|
||||
slog.Warn("cabana: unknown list row state dropped", "controller", controllerID(cc), "state", string(state))
|
||||
moduleLog.Warn("cabana: unknown list row state dropped", "controller", controllerID(cc), "state", string(state))
|
||||
continue
|
||||
}
|
||||
has[state] = true
|
||||
|
||||
Reference in New Issue
Block a user