-
Notifications
You must be signed in to change notification settings - Fork 76
/
logging.go
51 lines (46 loc) · 888 Bytes
/
logging.go
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
41
42
43
44
45
46
47
48
49
50
51
package webrtc
import (
"io/ioutil"
"log"
"os"
)
var (
INFO *log.Logger
WARN *log.Logger
ERROR *log.Logger
TRACE *log.Logger
)
// Logging verbosity level, from 0 (nothing) upwards.
func SetLoggingVerbosity(level int) {
// handle io.Writer
infoOut := ioutil.Discard
warnOut := ioutil.Discard
errOut := ioutil.Discard
traceOut := ioutil.Discard
// TODO: Better logging levels
if level > 0 {
errOut = os.Stdout
}
if level > 1 {
warnOut = os.Stdout
}
if level > 2 {
infoOut = os.Stdout
}
if level > 3 {
traceOut = os.Stdout
}
INFO = log.New(infoOut,
"INFO: ",
// log.Ldate|log.Ltime|log.Lshortfile)
log.Lshortfile)
WARN = log.New(warnOut,
"WARNING: ",
log.Ldate|log.Ltime|log.Lshortfile)
ERROR = log.New(errOut,
"ERROR: ",
log.Ldate|log.Ltime|log.Lshortfile)
TRACE = log.New(traceOut,
"TRACE: ",
log.Ldate|log.Ltime|log.Lshortfile)
}