mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-18 05:00:03 +02:00
src/main.go: in eventLoop() create a child logger with a signal parameter and use that to log messages.
This commit is contained in:
parent
8b86a5d34b
commit
bd412bb0eb
1 changed files with 7 additions and 6 deletions
13
src/main.go
13
src/main.go
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
@ -87,16 +86,18 @@ func signalEventLoop() {
|
|||
// Block until we get a signal.
|
||||
sig := <- sig_ch
|
||||
|
||||
l := logger.New("signal", sig)
|
||||
|
||||
switch sig {
|
||||
case syscall.SIGINT :
|
||||
logger.Info("Interrupted")
|
||||
l.Info("Interrupted")
|
||||
run = false
|
||||
case syscall.SIGTERM :
|
||||
logger.Info("Program was asked to terminate.", "signal", "SIGTERM")
|
||||
l.Info("Program was asked to terminate.")
|
||||
run = false
|
||||
// SIGHUP is sent when logfile is rotated.
|
||||
case syscall.SIGHUP :
|
||||
msg := "SIGHUP (Logfile was rotated): "
|
||||
msg := "Logfile was rotated: "
|
||||
|
||||
if logfd != nil {
|
||||
setLogFile()
|
||||
|
|
@ -105,9 +106,9 @@ func signalEventLoop() {
|
|||
msg += "No Filedescriptor to update (most likely uses standard out/err streams)"
|
||||
}
|
||||
|
||||
logger.Info(msg)
|
||||
l.Info(msg)
|
||||
default:
|
||||
logger.Warn("Unknown signal", "signal", sig)
|
||||
l.Warn("Unknown signal")
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue