-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (36 loc) · 773 Bytes
/
main.go
File metadata and controls
40 lines (36 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"time"
"os/signal"
"syscall"
"os"
log "github.com/sirupsen/logrus"
)
// main function
func main() {
customFormatter := new(log.TextFormatter)
customFormatter.TimestampFormat = "2006-01-02T15:04:05.000-07:00"
customFormatter.FullTimestamp = true
log.SetFormatter(customFormatter)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGUSR1)
go setLogger(c)
i:=0
for i<10{
log.Info("Printing Info ",i)
log.Debug("Printing Debug",i)
time.Sleep(5 * time.Second)
i+=1
}
}
func setLogger( types chan os.Signal){
for {
// Block until a signal is received.
log.Info(<-types)
if log.GetLevel()==log.InfoLevel{
log.SetLevel(log.DebugLevel)
}else if log.GetLevel()==log.DebugLevel{
log.SetLevel(log.InfoLevel)
}
}
}