Merge lp:~thumper/juju-core/show-log into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 1792
Proposed branch: lp:~thumper/juju-core/show-log
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 206 lines (+69/-23)
3 files modified
cmd/juju/main_test.go (+3/-2)
cmd/logging.go (+29/-18)
cmd/logging_test.go (+37/-3)
To merge this branch: bzr merge lp:~thumper/juju-core/show-log
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+185193@code.launchpad.net

Commit message

Make show-log an explicit arg.

This is part of the prelude to making --verbose mean
something else.

Also now, you can specify a log file and ask for show-log
and the logging goes to both places.

There is now a deprecation warning written out if people use
--verbose.

https://codereview.appspot.com/13352052/

Description of the change

Make show-log an explicit arg.

This is part of the prelude to making --verbose mean
something else.

Also now, you can specify a log file and ask for show-log
and the logging goes to both places.

There is now a deprecation warning written out if people use
--verbose.

https://codereview.appspot.com/13352052/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :
Download full text (7.2 KiB)

Reviewers: mp+185193_code.launchpad.net,

Message:
Please take a look.

Description:
Make show-log an explicit arg.

This is part of the prelude to making --verbose mean
something else.

Also now, you can specify a log file and ask for show-log
and the logging goes to both places.

There is now a deprecation warning written out if people use
--verbose.

https://code.launchpad.net/~thumper/juju-core/show-log/+merge/185193

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/13352052/

Affected files (+71, -23 lines):
   A [revision details]
   M cmd/juju/main_test.go
   M cmd/logging.go
   M cmd/logging_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20130912013106-u5aifia59afghpiv
+New revision: <email address hidden>

Index: cmd/logging.go
=== modified file 'cmd/logging.go'
--- cmd/logging.go 2013-06-20 11:03:10 +0000
+++ cmd/logging.go 2013-09-12 03:48:50 +0000
@@ -4,7 +4,6 @@
  package cmd

  import (
- "io"
   "os"

   "launchpad.net/gnuflag"
@@ -17,6 +16,7 @@
   Path string
   Verbose bool
   Debug bool
+ ShowLog bool
   Config string
  }

@@ -28,38 +28,49 @@
   f.BoolVar(&l.Verbose, "verbose", false, "if set, log additional messages")
   f.BoolVar(&l.Debug, "debug", false, "if set, log debugging messages")
   f.StringVar(&l.Config, "log-config", "", "specify log levels for modules")
+ f.BoolVar(&l.ShowLog, "show-log", false, "if set, write the log file to
stderr")
  }

  // Start starts logging using the given Context.
-func (l *Log) Start(ctx *Context) (err error) {
- var target io.Writer
+func (l *Log) Start(ctx *Context) error {
   if l.Path != "" {
    path := ctx.AbsPath(l.Path)
- target, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE,
0644)
+ target, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE,
0644)
    if err != nil {
     return err
    }
- } else if l.Verbose || l.Debug {
- target = ctx.Stderr
- }
-
- if target != nil {
    writer := loggo.NewSimpleWriter(target, &loggo.DefaultFormatter{})
- _, err = loggo.ReplaceDefaultWriter(writer)
+ err = loggo.RegisterWriter("logfile", writer, loggo.TRACE)
+ if err != nil {
+ return err
+ }
+ }
+ level := loggo.WARNING
+ if l.Verbose {
+ ctx.Stdout.Write([]byte("verbose is deprecated with the current meaning,
use show-log\n"))
+ l.ShowLog = true
+ }
+ if l.ShowLog {
+ level = loggo.INFO
+ }
+ if l.Debug {
+ l.ShowLog = true
+ level = loggo.DEBUG
+ }
+
+ if l.ShowLog {
+ // We replace the default writer to use ctx.Stderr rather than os.Stderr.
+ writer := loggo.NewSimpleWriter(ctx.Stderr, &loggo.DefaultFormatter{})
+ _, err := loggo.ReplaceDefaultWriter(writer)
    if err != nil {
     return err
    }
   } else {
    loggo.RemoveWriter("default")
   }
- if l.Verbose || l.Debug {
- level := loggo.INFO
- if l.Debug {
- level = loggo.DEBUG
- }
- // Set the level on the root logger.
- loggo.GetLogger("").SetLogLevel(level)
- }
+ // Set the level on the root logger.
+ loggo.GetLogger(""...

Read more...

Revision history for this message
Ian Booth (wallyworld) wrote :
Revision history for this message
Ian Booth (wallyworld) wrote :
Revision history for this message
Go Bot (go-bot) wrote :
Download full text (164.9 KiB)

The attempt to merge lp:~thumper/juju-core/show-log into lp:juju-core failed. Below is the output from the failed tests.

ok launchpad.net/juju-core/agent 0.755s
ok launchpad.net/juju-core/agent/tools 0.249s
ok launchpad.net/juju-core/bzr 6.747s
ok launchpad.net/juju-core/cert 2.357s
ok launchpad.net/juju-core/charm 0.537s
? launchpad.net/juju-core/charm/hooks [no test files]
ok launchpad.net/juju-core/cloudinit 0.020s
ok launchpad.net/juju-core/cmd 0.272s
? launchpad.net/juju-core/cmd/builddb [no test files]
? launchpad.net/juju-core/cmd/charmd [no test files]
? launchpad.net/juju-core/cmd/charmload [no test files]

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddMachineSuite.SetUpTest

[LOG] 37.26979 INFO juju mongod: error command line: unknown option sslOnNormalPorts
[LOG] 37.26983 INFO juju mongod: use --help for help
... Panic: no reachable servers (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:198
  in MgoDial
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:205
  in MgoSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:138
  in JujuConnSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:25
  in RepoSuite.SetUpTest

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddMachineSuite.TearDownTest

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/usr/lib/go/src/pkg/runtime/panic.c:487
  in panicstring
/usr/lib/go/src/pkg/runtime/os_linux.c:236
  in sigpanic
/home/tarmac/trees/src/launchpad.net/juju-core/state/state.go:1044
  in State.SetAdminMongoPassword
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:264
  in JujuConnSuite.tearDownConn
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:144
  in JujuConnSuite.TearDownTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:44
  in RepoSuite.TearDownTest

----------------------------------------------------------------------
PANIC: addmachine_test.go:82: AddMachineSuite.TestAddContainerToExistingMachine

... Panic: Fixture has panicked (see related PANIC)

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddRelationSuite.SetUpTest

... Panic: no reachable servers (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:198
  in MgoDial
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:205
  in MgoSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:138
  in JujuConnSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:25
  in RepoSuite.SetUpTest

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddRelationSuite.TearDownTest

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x414321)

/usr/lib/go/src/pkg/runti...

Revision history for this message
Go Bot (go-bot) wrote :
Download full text (164.9 KiB)

The attempt to merge lp:~thumper/juju-core/show-log into lp:juju-core failed. Below is the output from the failed tests.

ok launchpad.net/juju-core/agent 0.768s
ok launchpad.net/juju-core/agent/tools 0.254s
ok launchpad.net/juju-core/bzr 6.776s
ok launchpad.net/juju-core/cert 2.097s
ok launchpad.net/juju-core/charm 0.570s
? launchpad.net/juju-core/charm/hooks [no test files]
ok launchpad.net/juju-core/cloudinit 0.020s
ok launchpad.net/juju-core/cmd 0.260s
? launchpad.net/juju-core/cmd/builddb [no test files]
? launchpad.net/juju-core/cmd/charmd [no test files]
? launchpad.net/juju-core/cmd/charmload [no test files]

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddMachineSuite.SetUpTest

... Panic: no reachable servers (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:198
  in MgoDial
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:205
  in MgoSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:138
  in JujuConnSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:25
  in RepoSuite.SetUpTest

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddMachineSuite.TearDownTest

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/usr/lib/go/src/pkg/runtime/panic.c:487
  in panicstring
/usr/lib/go/src/pkg/runtime/os_linux.c:236
  in sigpanic
/home/tarmac/trees/src/launchpad.net/juju-core/state/state.go:1044
  in State.SetAdminMongoPassword
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:264
  in JujuConnSuite.tearDownConn
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:144
  in JujuConnSuite.TearDownTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:44
  in RepoSuite.TearDownTest

----------------------------------------------------------------------
PANIC: addmachine_test.go:82: AddMachineSuite.TestAddContainerToExistingMachine

... Panic: Fixture has panicked (see related PANIC)

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddRelationSuite.SetUpTest

... Panic: no reachable servers (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:198
  in MgoDial
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:205
  in MgoSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:138
  in JujuConnSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:25
  in RepoSuite.SetUpTest

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddRelationSuite.TearDownTest

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/usr/lib/go/src/pkg/runtime/panic.c:487
  in panicstring
/usr/lib/go/src/pkg/runtime/os_linux.c:236
  in sigpani...

Revision history for this message
Go Bot (go-bot) wrote :
Download full text (164.5 KiB)

The attempt to merge lp:~thumper/juju-core/show-log into lp:juju-core failed. Below is the output from the failed tests.

ok launchpad.net/juju-core/agent 0.748s
ok launchpad.net/juju-core/agent/tools 0.259s
ok launchpad.net/juju-core/bzr 6.771s
ok launchpad.net/juju-core/cert 2.964s
ok launchpad.net/juju-core/charm 0.552s
? launchpad.net/juju-core/charm/hooks [no test files]
ok launchpad.net/juju-core/cloudinit 0.025s
ok launchpad.net/juju-core/cmd 0.265s
? launchpad.net/juju-core/cmd/builddb [no test files]
? launchpad.net/juju-core/cmd/charmd [no test files]
? launchpad.net/juju-core/cmd/charmload [no test files]

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddMachineSuite.SetUpTest

[LOG] 61.02621 INFO juju mongod: error command line: unknown option sslOnNormalPorts
[LOG] 61.02625 INFO juju mongod: use --help for help
... Panic: no reachable servers (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:198
  in MgoDial
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:205
  in MgoSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:138
  in JujuConnSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:25
  in RepoSuite.SetUpTest

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddMachineSuite.TearDownTest

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/usr/lib/go/src/pkg/runtime/panic.c:487
  in panicstring
/usr/lib/go/src/pkg/runtime/os_linux.c:236
  in sigpanic
/home/tarmac/trees/src/launchpad.net/juju-core/state/state.go:1044
  in State.SetAdminMongoPassword
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:264
  in JujuConnSuite.tearDownConn
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:144
  in JujuConnSuite.TearDownTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:44
  in RepoSuite.TearDownTest

----------------------------------------------------------------------
PANIC: addmachine_test.go:82: AddMachineSuite.TestAddContainerToExistingMachine

... Panic: Fixture has panicked (see related PANIC)

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddRelationSuite.SetUpTest

... Panic: no reachable servers (PC=0x414321)

/usr/lib/go/src/pkg/runtime/panic.c:229
  in panic
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:198
  in MgoDial
/home/tarmac/trees/src/launchpad.net/juju-core/testing/mgo.go:205
  in MgoSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/conn.go:138
  in JujuConnSuite.SetUpTest
/home/tarmac/trees/src/launchpad.net/juju-core/juju/testing/repo.go:25
  in RepoSuite.SetUpTest

----------------------------------------------------------------------
PANIC: addmachine.go:0: AddRelationSuite.TearDownTest

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x414321)

/usr/lib/go/src/pkg/runti...

Revision history for this message
John A Meinel (jameinel) wrote :

I should have fixed the problem on the bot, I'll follow up if it keeps failing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/juju/main_test.go'
2--- cmd/juju/main_test.go 2013-08-21 18:38:22 +0000
3+++ cmd/juju/main_test.go 2013-09-12 04:14:12 +0000
4@@ -192,7 +192,7 @@
5 // Check global args work when specified before command
6 msg := breakJuju(c, "Bootstrap")
7 logpath := filepath.Join(c.MkDir(), "log")
8- out := badrun(c, 1, "--log-file", logpath, "--verbose", "--debug", "bootstrap")
9+ out := badrun(c, 1, "--log-file", logpath, "bootstrap")
10 c.Assert(out, gc.Equals, "error: "+msg+"\n")
11 content, err := ioutil.ReadFile(logpath)
12 c.Assert(err, gc.IsNil)
13@@ -205,7 +205,7 @@
14 // Check global args work when specified after command
15 msg := breakJuju(c, "Bootstrap")
16 logpath := filepath.Join(c.MkDir(), "log")
17- out := badrun(c, 1, "bootstrap", "--log-file", logpath, "--verbose", "--debug")
18+ out := badrun(c, 1, "bootstrap", "--log-file", logpath)
19 c.Assert(out, gc.Equals, "error: "+msg+"\n")
20 content, err := ioutil.ReadFile(logpath)
21 c.Assert(err, gc.IsNil)
22@@ -313,6 +313,7 @@
23 "-h, --help .*",
24 "--log-config .*",
25 "--log-file .*",
26+ "--show-log .*",
27 "-v, --verbose .*",
28 }
29
30
31=== modified file 'cmd/logging.go'
32--- cmd/logging.go 2013-06-20 11:03:10 +0000
33+++ cmd/logging.go 2013-09-12 04:14:12 +0000
34@@ -4,7 +4,6 @@
35 package cmd
36
37 import (
38- "io"
39 "os"
40
41 "launchpad.net/gnuflag"
42@@ -17,6 +16,7 @@
43 Path string
44 Verbose bool
45 Debug bool
46+ ShowLog bool
47 Config string
48 }
49
50@@ -28,38 +28,49 @@
51 f.BoolVar(&l.Verbose, "verbose", false, "if set, log additional messages")
52 f.BoolVar(&l.Debug, "debug", false, "if set, log debugging messages")
53 f.StringVar(&l.Config, "log-config", "", "specify log levels for modules")
54+ f.BoolVar(&l.ShowLog, "show-log", false, "if set, write the log file to stderr")
55 }
56
57 // Start starts logging using the given Context.
58-func (l *Log) Start(ctx *Context) (err error) {
59- var target io.Writer
60+func (l *Log) Start(ctx *Context) error {
61 if l.Path != "" {
62 path := ctx.AbsPath(l.Path)
63- target, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
64+ target, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
65 if err != nil {
66 return err
67 }
68- } else if l.Verbose || l.Debug {
69- target = ctx.Stderr
70- }
71-
72- if target != nil {
73 writer := loggo.NewSimpleWriter(target, &loggo.DefaultFormatter{})
74- _, err = loggo.ReplaceDefaultWriter(writer)
75+ err = loggo.RegisterWriter("logfile", writer, loggo.TRACE)
76+ if err != nil {
77+ return err
78+ }
79+ }
80+ level := loggo.WARNING
81+ if l.Verbose {
82+ ctx.Stdout.Write([]byte("verbose is deprecated with the current meaning, use show-log\n"))
83+ l.ShowLog = true
84+ }
85+ if l.ShowLog {
86+ level = loggo.INFO
87+ }
88+ if l.Debug {
89+ l.ShowLog = true
90+ level = loggo.DEBUG
91+ }
92+
93+ if l.ShowLog {
94+ // We replace the default writer to use ctx.Stderr rather than os.Stderr.
95+ writer := loggo.NewSimpleWriter(ctx.Stderr, &loggo.DefaultFormatter{})
96+ _, err := loggo.ReplaceDefaultWriter(writer)
97 if err != nil {
98 return err
99 }
100 } else {
101 loggo.RemoveWriter("default")
102 }
103- if l.Verbose || l.Debug {
104- level := loggo.INFO
105- if l.Debug {
106- level = loggo.DEBUG
107- }
108- // Set the level on the root logger.
109- loggo.GetLogger("").SetLogLevel(level)
110- }
111+ // Set the level on the root logger.
112+ loggo.GetLogger("").SetLogLevel(level)
113+ // Override the logging config with specified logging config.
114 loggo.ConfigureLoggers(l.Config)
115 return nil
116 }
117
118=== modified file 'cmd/logging_test.go'
119--- cmd/logging_test.go 2013-08-19 11:17:19 +0000
120+++ cmd/logging_test.go 2013-09-12 04:14:12 +0000
121@@ -20,6 +20,11 @@
122
123 var _ = gc.Suite(&LogSuite{})
124
125+func (s *LogSuite) TearDownTest(c *gc.C) {
126+ loggo.ResetLoggers()
127+ loggo.ResetWriters()
128+}
129+
130 func (s *LogSuite) TestAddFlags(c *gc.C) {
131 l := &cmd.Log{}
132 f := testing.NewFlagSet()
133@@ -48,6 +53,8 @@
134 c.Assert(err, gc.IsNil)
135
136 c.Assert(loggo.GetLogger("").LogLevel(), gc.Equals, loggo.INFO)
137+ c.Assert(testing.Stderr(ctx), gc.Equals, "")
138+ c.Assert(testing.Stdout(ctx), gc.Equals, "verbose is deprecated with the current meaning, use show-log\n")
139 }
140
141 func (s *LogSuite) TestDebugSetsLogLevel(c *gc.C) {
142@@ -57,6 +64,19 @@
143 c.Assert(err, gc.IsNil)
144
145 c.Assert(loggo.GetLogger("").LogLevel(), gc.Equals, loggo.DEBUG)
146+ c.Assert(testing.Stderr(ctx), gc.Equals, "")
147+ c.Assert(testing.Stdout(ctx), gc.Equals, "")
148+}
149+
150+func (s *LogSuite) TestShowLogSetsLogLevel(c *gc.C) {
151+ l := &cmd.Log{ShowLog: true}
152+ ctx := testing.Context(c)
153+ err := l.Start(ctx)
154+ c.Assert(err, gc.IsNil)
155+
156+ c.Assert(loggo.GetLogger("").LogLevel(), gc.Equals, loggo.INFO)
157+ c.Assert(testing.Stderr(ctx), gc.Equals, "")
158+ c.Assert(testing.Stdout(ctx), gc.Equals, "")
159 }
160
161 func (s *LogSuite) TestStderr(c *gc.C) {
162@@ -65,7 +85,7 @@
163 err := l.Start(ctx)
164 c.Assert(err, gc.IsNil)
165 log.Infof("hello")
166- c.Assert(bufferString(ctx.Stderr), gc.Matches, `^.* INFO .* hello\n`)
167+ c.Assert(testing.Stderr(ctx), gc.Matches, `^.* INFO .* hello\n`)
168 }
169
170 func (s *LogSuite) TestRelPathLog(c *gc.C) {
171@@ -74,10 +94,11 @@
172 err := l.Start(ctx)
173 c.Assert(err, gc.IsNil)
174 log.Infof("hello")
175- c.Assert(bufferString(ctx.Stderr), gc.Equals, "")
176 content, err := ioutil.ReadFile(filepath.Join(ctx.Dir, "foo.log"))
177 c.Assert(err, gc.IsNil)
178 c.Assert(string(content), gc.Matches, `^.* INFO .* hello\n`)
179+ c.Assert(testing.Stderr(ctx), gc.Equals, "")
180+ c.Assert(testing.Stdout(ctx), gc.Equals, "")
181 }
182
183 func (s *LogSuite) TestAbsPathLog(c *gc.C) {
184@@ -87,8 +108,21 @@
185 err := l.Start(ctx)
186 c.Assert(err, gc.IsNil)
187 log.Infof("hello")
188- c.Assert(bufferString(ctx.Stderr), gc.Equals, "")
189+ c.Assert(testing.Stderr(ctx), gc.Equals, "")
190 content, err := ioutil.ReadFile(path)
191 c.Assert(err, gc.IsNil)
192 c.Assert(string(content), gc.Matches, `^.* INFO .* hello\n`)
193 }
194+
195+func (s *LogSuite) TestLoggingToFileAndStderr(c *gc.C) {
196+ l := &cmd.Log{Path: "foo.log", Config: "<root>=INFO", ShowLog: true}
197+ ctx := testing.Context(c)
198+ err := l.Start(ctx)
199+ c.Assert(err, gc.IsNil)
200+ log.Infof("hello")
201+ content, err := ioutil.ReadFile(filepath.Join(ctx.Dir, "foo.log"))
202+ c.Assert(err, gc.IsNil)
203+ c.Assert(string(content), gc.Matches, `^.* INFO .* hello\n`)
204+ c.Assert(testing.Stderr(ctx), gc.Matches, `^.* INFO .* hello\n`)
205+ c.Assert(testing.Stdout(ctx), gc.Equals, "")
206+}

Subscribers

People subscribed via source and target branches

to status/vote changes: