Peter Kurfer
9ea9a8f658
Some checks failed
Go build / build (push) Failing after 1m58s
- setup ent scheme - add command to create users - document API - add helpers to create migrations - add command to run migrations - add basic compose file
20 lines
395 B
Go
20 lines
395 B
Go
package logging
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
)
|
|
|
|
var loggerKey struct{}
|
|
|
|
func ContextWithLogger(ctx context.Context, logger *slog.Logger) context.Context {
|
|
return context.WithValue(ctx, loggerKey, logger)
|
|
}
|
|
|
|
func GetLogger(ctx context.Context) *slog.Logger {
|
|
contextLogger := ctx.Value(loggerKey).(*slog.Logger)
|
|
if contextLogger == nil {
|
|
return slog.Default()
|
|
}
|
|
return contextLogger
|
|
}
|