Skip to content

Commit

Permalink
fix(log): contextual logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hekike committed Nov 11, 2024
1 parent 327d7aa commit 68259d5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func main() {
app.SetGlobals()

logger := app.Logger
slog.SetDefault(logger)

logger.Info("starting OpenMeter server", "config", map[string]string{
"address": conf.Address,
Expand Down
1 change: 1 addition & 0 deletions cmd/sink-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func main() {
app.SetGlobals()

logger := app.Logger
slog.SetDefault(logger)

logger.Info("starting OpenMeter sink worker", "config", map[string]string{
"telemetry.address": conf.Telemetry.Address,
Expand Down
2 changes: 1 addition & 1 deletion openmeter/entitlement/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type EntitlementRepo interface {
// GetScheduledEntitlements returns all scheduled entitlements for a given subject-feature pair that become inactive after the given time, sorted by the time they become active
GetScheduledEntitlements(ctx context.Context, namespace string, subjectKey models.SubjectKey, featureKey string, starting time.Time) ([]Entitlement, error)

// GetEntitlementValue deactivates an entitlement by setting the activeTo time. If the entitlement is already deactivated, it returns an error.
// DeactivateEntitlement deactivates an entitlement by setting the activeTo time. If the entitlement is already deactivated, it returns an error.
DeactivateEntitlement(ctx context.Context, entitlementID models.NamespacedID, at time.Time) error

CreateEntitlement(ctx context.Context, entitlement CreateEntitlementRepoInputs) (*Entitlement, error)
Expand Down
2 changes: 2 additions & 0 deletions pkg/framework/operation/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"log/slog"
)

var _ slog.Handler = (*Handler)(nil)

// NewLogHandler returns a new [slog.Handler]
func NewLogHandler(handler slog.Handler) slog.Handler {
return Handler{handler}
Expand Down

0 comments on commit 68259d5

Please sign in to comment.