-
Notifications
You must be signed in to change notification settings - Fork 42
/
log_test.go
47 lines (36 loc) · 1.14 KB
/
log_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
// Copyright 2013, 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package testing
import (
gc "gopkg.in/check.v1"
"github.com/juju/loggo/v2"
)
type logSuite struct{}
var _ = gc.Suite(&logSuite{})
func (*logSuite) TestLog(c *gc.C) {
logger := loggo.GetLogger("test")
jujuLogger := loggo.GetLogger("juju")
logConfig = "<root>=DEBUG;juju=TRACE"
c.Assert(logger.EffectiveLogLevel(), gc.Equals, loggo.WARNING)
var suite LoggingSuite
suite.SetUpSuite(c)
c.Assert(logger.EffectiveLogLevel(), gc.Equals, loggo.DEBUG)
c.Assert(jujuLogger.EffectiveLogLevel(), gc.Equals, loggo.TRACE)
logger.Debugf("message 1")
logger.Tracef("message 2")
jujuLogger.Tracef("message 3")
c.Assert(c.GetTestLog(), gc.Matches,
".*DEBUG test message 1\n"+
".*TRACE juju message 3\n",
)
suite.TearDownSuite(c)
logger.Debugf("message 1")
logger.Tracef("message 2")
jujuLogger.Tracef("message 3")
c.Assert(c.GetTestLog(), gc.Matches,
".*DEBUG test message 1\n"+
".*TRACE juju message 3\n$",
)
c.Assert(logger.EffectiveLogLevel(), gc.Equals, loggo.WARNING)
c.Assert(jujuLogger.EffectiveLogLevel(), gc.Equals, loggo.WARNING)
}