parser/logger.go

31 lines
521 B
Go
Raw Normal View History

2018-05-17 12:11:33 +02:00
package main
import (
"os"
"os/signal"
"syscall"
"git.fuyu.moe/Fuyu/flog"
)
func setLogger() {
f, err := os.OpenFile(`log`, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}
flog.Output = f
flog.MinLevel = flog.LevelInfo
flog.MinStackLevel = flog.LevelWarning
}
func catchSignals() {
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
s := <-sc
flog.Info(`Stopping, signal: `, s)
os.Exit(0)
}()
}