-
Notifications
You must be signed in to change notification settings - Fork 0
/
builtin_test.go
59 lines (45 loc) · 1.35 KB
/
builtin_test.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
52
53
54
55
56
57
58
59
package logger
import (
"log"
"os"
. "gopkg.in/check.v1"
)
type BuiltinTestSuite struct {
}
var (
_ = Suite(&LevelTestSuite{})
)
func ExampleBuiltinDebug() {
logger := NewBuiltinLogger(log.New(os.Stdout, "", 0), LevelDebug)
logger.Debug("message1", "message2")
// Output:
// [DEBUG] message1message2
}
func ExampleBuiltinDebugf() {
logger := NewBuiltinLogger(log.New(os.Stdout, "", 0), LevelDebug)
logger.Debugf("debug messages: %s, %s", "message1", "message2")
// Output:
// [DEBUG] debug messages: message1, message2
}
func ExampleBuiltinDebugDisabled() {
logger := NewBuiltinLogger(log.New(os.Stdout, "", 0), LevelError)
logger.Debug("message")
// Output:
}
func ExampleBuiltinStderr() {
logger := NewBuiltinLogger(log.New(os.Stderr, "prefix", 0), LevelDebug)
logger.Alert("message")
// Error:
// prefix [ALERT] message
}
func (s *BuiltinTestSuite) TestIsLevelEnabled(c *C) {
logger := NewBuiltinLogger(log.New(os.Stdout, "", 0), LevelError)
c.Assert(logger.IsDebugEnabled(), Equals, false)
c.Assert(logger.IsInfoEnabled(), Equals, false)
c.Assert(logger.IsNoticeEnabled(), Equals, false)
c.Assert(logger.IsWarningEnabled(), Equals, false)
c.Assert(logger.IsErrorEnabled(), Equals, true)
c.Assert(logger.IsAlertEnabled(), Equals, true)
c.Assert(logger.IsCriticalEnabled(), Equals, true)
c.Assert(logger.IsEmergencyEnabled(), Equals, true)
}