aboutsummaryrefslogtreecommitdiffhomepage
path: root/sigtrap.go
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2019-10-28 14:39:37 -0600
committerGitHub <[email protected]>2019-10-28 14:39:37 -0600
commitb00dfd3965f400956c5bb5b388e9d54ef98052e5 (patch)
tree44517743815327f7ef63405b3a13e54f7f20c885 /sigtrap.go
parent6c533558a3db4b30a6b7a81d19ac180fe2000ca2 (diff)
downloadcaddy-b00dfd3965f400956c5bb5b388e9d54ef98052e5.tar.gz
caddy-b00dfd3965f400956c5bb5b388e9d54ef98052e5.zip
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
Diffstat (limited to 'sigtrap.go')
-rw-r--r--sigtrap.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/sigtrap.go b/sigtrap.go
index 76bb6664a..88dbb6da6 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)
}