SetupSignalHandler listens to signals and toggles the log level to DEBUG mode when it received a SIGUSR2 signal. Another SIGUSR2 toggles the log level back to the old level.
()
| 12 | // mode when it received a SIGUSR2 signal. Another SIGUSR2 toggles the log |
| 13 | // level back to the old level. |
| 14 | func (k *Kite) SetupSignalHandler() { |
| 15 | c := make(chan os.Signal, 1) |
| 16 | |
| 17 | signal.Notify(c, syscall.SIGUSR2) |
| 18 | go func() { |
| 19 | for s := range c { |
| 20 | k.Log.Info("Got signal: %s", s) |
| 21 | |
| 22 | if debugMode { |
| 23 | // toogle back to old settings. |
| 24 | k.Log.Info("Disabling debug mode") |
| 25 | if k.SetLogLevel == nil { |
| 26 | k.Log.Error("SetLogLevel is not defined") |
| 27 | continue |
| 28 | } |
| 29 | |
| 30 | k.SetLogLevel(getLogLevel()) |
| 31 | debugMode = false |
| 32 | } else { |
| 33 | k.Log.Info("Enabling debug mode") |
| 34 | if k.SetLogLevel == nil { |
| 35 | k.Log.Error("SetLogLevel is not defined") |
| 36 | continue |
| 37 | } |
| 38 | |
| 39 | k.SetLogLevel(DEBUG) |
| 40 | debugMode = true |
| 41 | } |
| 42 | } |
| 43 | }() |
| 44 | } |
nothing calls this directly
no test coverage detected