Major changes: - Add internal/logging package with field constants, context propagation, sensitive data auto-redaction, and per-component log levels - Add worker timeout constants (TimeoutQuickOp, TimeoutHealthCheck, etc.) - Extend SDLC with callback handlers, generate endpoints, and executor - Add new cookbook trees for aeries and slackpath progression - Add skeleton templates for queue, realtime, and microservices - Add worker component template with async job processing - Refactor services and handlers to use new logging infrastructure - Split component.go into component_infra.go and component_listing.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
66 lines
1.1 KiB
Go
66 lines
1.1 KiB
Go
package logging
|
|
|
|
import (
|
|
"log/slog"
|
|
"strings"
|
|
)
|
|
|
|
// Level represents a logging level.
|
|
type Level int
|
|
|
|
const (
|
|
LevelDebug Level = iota
|
|
LevelInfo
|
|
LevelWarn
|
|
LevelError
|
|
)
|
|
|
|
// String returns the string representation of the level.
|
|
func (l Level) String() string {
|
|
switch l {
|
|
case LevelDebug:
|
|
return "debug"
|
|
case LevelInfo:
|
|
return "info"
|
|
case LevelWarn:
|
|
return "warn"
|
|
case LevelError:
|
|
return "error"
|
|
default:
|
|
return "info"
|
|
}
|
|
}
|
|
|
|
// SlogLevel converts to slog.Level.
|
|
func (l Level) SlogLevel() slog.Level {
|
|
switch l {
|
|
case LevelDebug:
|
|
return slog.LevelDebug
|
|
case LevelInfo:
|
|
return slog.LevelInfo
|
|
case LevelWarn:
|
|
return slog.LevelWarn
|
|
case LevelError:
|
|
return slog.LevelError
|
|
default:
|
|
return slog.LevelInfo
|
|
}
|
|
}
|
|
|
|
// ParseLevel parses a string into a Level.
|
|
// Returns LevelInfo if the string is not recognized.
|
|
func ParseLevel(s string) Level {
|
|
switch strings.ToLower(strings.TrimSpace(s)) {
|
|
case "debug":
|
|
return LevelDebug
|
|
case "info":
|
|
return LevelInfo
|
|
case "warn", "warning":
|
|
return LevelWarn
|
|
case "error", "err":
|
|
return LevelError
|
|
default:
|
|
return LevelInfo
|
|
}
|
|
}
|