Improved logging.

This commit is contained in:
Mikkel Krautz 2011-11-10 00:38:59 +01:00
parent 244027d41b
commit b13dbeadf1
6 changed files with 82 additions and 6 deletions

View file

@ -5,6 +5,7 @@
package main
import (
"fmt"
"os"
"os/signal"
)
@ -12,9 +13,17 @@ import (
func SignalHandler() {
for {
sig := <-signal.Incoming
if sig != os.SIGINT && sig != os.SIGTERM {
if sig == os.SIGUSR2 {
err := LogTarget.Rotate()
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to rotate log file: %v", err)
}
continue
}
os.Exit(0)
if sig == os.SIGINT || sig == os.SIGTERM {
os.Exit(0)
}
}
}