feat(docker-watcher): phase 12 - hardening
Blue-green zero-downtime deploys, promote flow validation. Dual auth: local (bcrypt + JWT) and OAuth2/OIDC (any provider). Auth middleware, login page, auth settings UI. Structured logging (slog JSON), config export to YAML. Graceful shutdown with deploy draining. Multi-stage Dockerfile and production docker-compose.yml. Swap phase order: Volumes & Env before UI Polish.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Setup initializes the global structured JSON logger.
|
||||
// It replaces the default slog handler with a JSON handler writing to stdout.
|
||||
func Setup() {
|
||||
handler := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: slog.LevelInfo,
|
||||
})
|
||||
slog.SetDefault(slog.New(handler))
|
||||
}
|
||||
|
||||
// SetupWithWriter initializes the global structured JSON logger writing to the given writer.
|
||||
func SetupWithWriter(w io.Writer) {
|
||||
handler := slog.NewJSONHandler(w, &slog.HandlerOptions{
|
||||
Level: slog.LevelInfo,
|
||||
})
|
||||
slog.SetDefault(slog.New(handler))
|
||||
}
|
||||
|
||||
// DeployContext returns a logger enriched with deploy-specific attributes.
|
||||
func DeployContext(project, stage, tag, instanceID string) *slog.Logger {
|
||||
return slog.With(
|
||||
slog.String("project", project),
|
||||
slog.String("stage", stage),
|
||||
slog.String("tag", tag),
|
||||
slog.String("instance_id", instanceID),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user