MCPcopy
hub / github.com/eth0izzle/shhgit / Log

Method Log

core/log.go:41–64  ·  view source on GitHub ↗
(level int, format string, args ...interface{})

Source from the content-addressed store, hash-verified

39}
40
41func (l *Logger) Log(level int, format string, args ...interface{}) {
42 l.Lock()
43 defer l.Unlock()
44
45 if level == DEBUG && !l.debug {
46 return
47 }
48
49 if c, ok := LogColors[level]; ok {
50 c.Printf(format+"\n", args...)
51 } else {
52 fmt.Printf(format+"\n", args...)
53 }
54
55 if level > INFO && session.Config.SlackWebhook != "" {
56 values := map[string]string{"text": fmt.Sprintf(format+"\n", args...)}
57 jsonValue, _ := json.Marshal(values)
58 http.Post(session.Config.SlackWebhook, "application/json", bytes.NewBuffer(jsonValue))
59 }
60
61 if level == FATAL {
62 os.Exit(1)
63 }
64}
65
66func (l *Logger) Fatal(format string, args ...interface{}) {
67 l.Log(FATAL, format, args...)

Callers 6

FatalMethod · 0.95
ErrorMethod · 0.95
WarnMethod · 0.95
ImportantMethod · 0.95
InfoMethod · 0.95
DebugMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected