From b00dfd3965f400956c5bb5b388e9d54ef98052e5 Mon Sep 17 00:00:00 2001 From: Matt Holt Date: Mon, 28 Oct 2019 14:39:37 -0600 Subject: v2: Logging! (#2831) * logging: Initial implementation * logging: More encoder formats, better defaults * logging: Fix repetition bug with FilterEncoder; add more presets * logging: DiscardWriter; delete or no-op logs that discard their output * logging: Add http.handlers.log module; enhance Replacer methods The Replacer interface has new methods to customize how to handle empty or unrecognized placeholders. Closes #2815. * logging: Overhaul HTTP logging, fix bugs, improve filtering, etc. * logging: General cleanup, begin transitioning to using new loggers * Fixes after merge conflict --- sigtrap.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sigtrap.go') diff --git a/sigtrap.go b/sigtrap.go index 76bb666..88dbb6d 100644 --- a/sigtrap.go +++ b/sigtrap.go @@ -15,9 +15,10 @@ package caddy import ( - "log" "os" "os/signal" + + "go.uber.org/zap" ) // TrapSignals create signal/interrupt handlers as best it can for the @@ -41,11 +42,11 @@ func trapSignalsCrossPlatform() { <-shutdown if i > 0 { - log.Println("[INFO] SIGINT: Force quit") + Log().Warn("force quit", zap.String("signal", "SIGINT")) os.Exit(ExitCodeForceQuit) } - log.Println("[INFO] SIGINT: Shutting down") + Log().Info("shutting down", zap.String("signal", "SIGINT")) go gracefulStop("SIGINT") } }() @@ -57,11 +58,14 @@ func gracefulStop(sigName string) { err := stopAndCleanup() if err != nil { - log.Printf("[ERROR] %s stop: %v", sigName, err) + Log().Error("stopping", + zap.String("signal", sigName), + zap.Error(err), + ) exitCode = ExitCodeFailedQuit } - log.Printf("[INFO] %s: Shutdown done", sigName) + Log().Info("shutdown done", zap.String("signal", sigName)) os.Exit(exitCode) } -- cgit v1.2.3