You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
521 B

  1. package main
  2. import (
  3. "os"
  4. "os/signal"
  5. "syscall"
  6. "git.fuyu.moe/Fuyu/flog"
  7. )
  8. func setLogger() {
  9. f, err := os.OpenFile(`log`, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644)
  10. if err != nil {
  11. panic(err)
  12. }
  13. flog.Output = f
  14. flog.MinLevel = flog.LevelInfo
  15. flog.MinStackLevel = flog.LevelWarning
  16. }
  17. func catchSignals() {
  18. sc := make(chan os.Signal, 1)
  19. signal.Notify(sc, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
  20. go func() {
  21. s := <-sc
  22. flog.Info(`Stopping, signal: `, s)
  23. os.Exit(0)
  24. }()
  25. }