Debian Codegraph @

logger.go

raw symbols SCIP
1 package slack
2
3 import (
4 "fmt"
5 )
6
7 // logger is a logger interface compatible with both stdlib and some
8 // 3rd party loggers.
9 type logger interface {
10 Output(int, string) error
11 }
12
13 // ilogger represents the internal logging api we use.
14 type ilogger interface {
15 logger
16 Print(...interface{})
17 Printf(string, ...interface{})
18 Println(...interface{})
19 }
20
21 type Debug interface {
22 Debug() bool
23
24 // Debugf print a formatted debug line.
25 Debugf(format string, v ...interface{})
26 // Debugln print a debug line.
27 Debugln(v ...interface{})
28 }
29
30 // internalLog implements the additional methods used by our internal logging.
31 type internalLog struct {
32 logger
33 }
34
35 // Println replicates the behaviour of the standard logger.
36 func (t internalLog) Println(v ...interface{}) {
37 t.Output(2, fmt.Sprintln(v...))
38 }
39
40 // Printf replicates the behaviour of the standard logger.
41 func (t internalLog) Printf(format string, v ...interface{}) {
42 t.Output(2, fmt.Sprintf(format, v...))
43 }
44
45 // Print replicates the behaviour of the standard logger.
46 func (t internalLog) Print(v ...interface{}) {
47 t.Output(2, fmt.Sprint(v...))
48 }
49
50 type discard struct{}
51
52 func (t discard) Debug() bool {
53 return false
54 }
55
56 // Debugf print a formatted debug line.
57 func (t discard) Debugf(format string, v ...interface{}) {}
58
59 // Debugln print a debug line.
60 func (t discard) Debugln(v ...interface{}) {}