MCPcopy Index your code
hub / github.com/koding/kite / SetupSignalHandler

Method SetupSignalHandler

logger_unix.go:14–44  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

12// mode when it received a SIGUSR2 signal. Another SIGUSR2 toggles the log
13// level back to the old level.
14func (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}

Callers

nothing calls this directly

Calls 3

getLogLevelFunction · 0.85
InfoMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected