Merge lp:~thumper/juju-core/update-loggo into lp:~juju/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Merged at revision: 1263
Proposed branch: lp:~thumper/juju-core/update-loggo
Merge into: lp:~juju/juju-core/trunk
Diff against target: 352 lines (+43/-45)
9 files modified
cmd/builddb/main.go (+5/-5)
cmd/juju/main_test.go (+1/-1)
cmd/logging.go (+3/-3)
cmd/logging_test.go (+2/-4)
log/log.go (+5/-5)
testing/log.go (+2/-2)
worker/provisioner/provisioner.go (+2/-2)
worker/provisioner/provisioner_task.go (+22/-22)
worker/uniter/jujuc/juju-log_test.go (+1/-1)
To merge this branch: bzr merge lp:~thumper/juju-core/update-loggo
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+168342@code.launchpad.net

Description of the change

Updates for latest loggo.

Since we don't yet have dependency management, the latest
changes to loggo are unpushed until I get this agreed upon.

https://codereview.appspot.com/10125046/

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

Reviewers: mp+168342_code.launchpad.net,

Message:
Please take a look.

Description:
Updates for latest loggo.

Since we don't yet have dependency management, the latest
changes to loggo are unpushed until I get this agreed upon.

https://code.launchpad.net/~thumper/juju-core/update-loggo/+merge/168342

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M cmd/builddb/main.go
   M cmd/juju/main_test.go
   M cmd/logging.go
   M cmd/logging_test.go
   M log/log.go
   M testing/log.go
   M worker/provisioner/provisioner.go
   M worker/provisioner/provisioner_task.go
   M worker/uniter/jujuc/juju-log_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: <email address hidden>
+New revision: <email address hidden>

Index: cmd/logging.go
=== modified file 'cmd/logging.go'
--- cmd/logging.go 2013-06-07 01:00:23 +0000
+++ cmd/logging.go 2013-06-10 04:25:51 +0000
@@ -57,9 +57,9 @@
    if l.Debug {
     level = loggo.DEBUG
    }
- logger := loggo.GetLogger("juju")
- logger.SetLogLevel(level)
+ // Set the level on the root logger.
+ loggo.GetLogger("").SetLogLevel(level)
   }
- loggo.ConfigureLogging(l.Config)
+ loggo.ConfigureLoggers(l.Config)
   return nil
  }

Index: cmd/logging_test.go
=== modified file 'cmd/logging_test.go'
--- cmd/logging_test.go 2013-06-06 03:55:22 +0000
+++ cmd/logging_test.go 2013-06-10 04:25:51 +0000
@@ -46,8 +46,7 @@
   err := l.Start(ctx)
   c.Assert(err, IsNil)

- logger := loggo.GetLogger("juju")
- c.Assert(logger.GetLogLevel(), Equals, loggo.INFO)
+ c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.INFO)
  }

  func (s *LogSuite) TestDebugSetsLogLevel(c *C) {
@@ -56,8 +55,7 @@
   err := l.Start(ctx)
   c.Assert(err, IsNil)

- logger := loggo.GetLogger("juju")
- c.Assert(logger.GetLogLevel(), Equals, loggo.DEBUG)
+ c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.DEBUG)
  }

  func (s *LogSuite) TestStderr(c *C) {

Index: cmd/builddb/main.go
=== modified file 'cmd/builddb/main.go'
--- cmd/builddb/main.go 2013-05-29 05:29:57 +0000
+++ cmd/builddb/main.go 2013-06-10 04:25:51 +0000
@@ -57,13 +57,13 @@
    return err
   }

- logger.Info("Waiting for unit to reach %q status...",
params.StatusStarted)
+ logger.Infof("Waiting for unit to reach %q status...",
params.StatusStarted)
   unit := units[0]
   last, info, err := unit.Status()
   if err != nil {
    return err
   }
- logger.Info("Unit status is %q: %s", last, info)
+ logger.Infof("Unit status is %q: %s", last, info)
   for last != params.StatusStarted {
    time.Sleep(2 * time.Second)
    if err := unit.Refresh(); err != nil {
@@ -74,7 +74,7 @@
     return err
    }
    if status != last {
- logger.Info("Unit status is %q: %s", status, info)
+ logger.Infof("Unit status is %q: %s", status, info)
     last = status
    }
   }
@@ -82,7 +82,7 @@
   if !ok {
    return fmt.Errorf("cannot retrieve files: build unit lacks a
public-address...

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

You didn't really summarize what the changes are. I'm guessing it is
mostly changing names from "Info" to "Infof" to follow the common idiom
that things which take a format + args end in an extra 'f'. (printf,
etc).

I think I'm fine with that, but I haven't seen it discussed.

LGTM

https://codereview.appspot.com/10125046/

Revision history for this message
Roger Peppe (rogpeppe) wrote :
Download full text (16.7 KiB)

LGTM

could I suggest also adding the various log functions to
.lbox.check ? perhaps as a separate CL

(I believe the version check should change there - currently
it checks that the Go version is devel, but 1.1 is also
sufficient now).

On 10 June 2013 05:31, Tim Penhey <email address hidden> wrote:
> Reviewers: mp+168342_code.launchpad.net,
>
> Message:
> Please take a look.
>
> Description:
> Updates for latest loggo.
>
> Since we don't yet have dependency management, the latest
> changes to loggo are unpushed until I get this agreed upon.
>
> https://code.launchpad.net/~thumper/juju-core/update-loggo/+merge/168342
>
> (do not edit description out of merge proposal)
>
>
> Please review this at https://codereview.appspot.com/10125046/
>
> Affected files:
> A [revision details]
> M cmd/builddb/main.go
> M cmd/juju/main_test.go
> M cmd/logging.go
> M cmd/logging_test.go
> M log/log.go
> M testing/log.go
> M worker/provisioner/provisioner.go
> M worker/provisioner/provisioner_task.go
> M worker/uniter/jujuc/juju-log_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: <email address hidden>
> +New revision: <email address hidden>
>
> Index: cmd/logging.go
> === modified file 'cmd/logging.go'
> --- cmd/logging.go 2013-06-07 01:00:23 +0000
> +++ cmd/logging.go 2013-06-10 04:25:51 +0000
> @@ -57,9 +57,9 @@
> if l.Debug {
> level = loggo.DEBUG
> }
> - logger := loggo.GetLogger("juju")
> - logger.SetLogLevel(level)
> + // Set the level on the root logger.
> + loggo.GetLogger("").SetLogLevel(level)
> }
> - loggo.ConfigureLogging(l.Config)
> + loggo.ConfigureLoggers(l.Config)
> return nil
> }
>
>
> Index: cmd/logging_test.go
> === modified file 'cmd/logging_test.go'
> --- cmd/logging_test.go 2013-06-06 03:55:22 +0000
> +++ cmd/logging_test.go 2013-06-10 04:25:51 +0000
> @@ -46,8 +46,7 @@
> err := l.Start(ctx)
> c.Assert(err, IsNil)
>
> - logger := loggo.GetLogger("juju")
> - c.Assert(logger.GetLogLevel(), Equals, loggo.INFO)
> + c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.INFO)
> }
>
> func (s *LogSuite) TestDebugSetsLogLevel(c *C) {
> @@ -56,8 +55,7 @@
> err := l.Start(ctx)
> c.Assert(err, IsNil)
>
> - logger := loggo.GetLogger("juju")
> - c.Assert(logger.GetLogLevel(), Equals, loggo.DEBUG)
> + c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.DEBUG)
> }
>
> func (s *LogSuite) TestStderr(c *C) {
>
>
> Index: cmd/builddb/main.go
> === modified file 'cmd/builddb/main.go'
> --- cmd/builddb/main.go 2013-05-29 05:29:57 +0000
> +++ cmd/builddb/main.go 2013-06-10 04:25:51 +0000
> @@ -57,13 +57,13 @@
> return err
> }
>
> - logger.Info("Waiting for unit to reach %q status...",
> params.StatusStarted)
> + logger.Infof("Wai...

Revision history for this message
Roger Peppe (rogpeppe) wrote :

This CL should give some context: https://codereview.appspot.com/10043045/

On 10 June 2013 09:28, John A Meinel <email address hidden> wrote:
> You didn't really summarize what the changes are. I'm guessing it is
> mostly changing names from "Info" to "Infof" to follow the common idiom
> that things which take a format + args end in an extra 'f'. (printf,
> etc).
>
> I think I'm fine with that, but I haven't seen it discussed.
>
> LGTM
>
>
> https://codereview.appspot.com/10125046/
>
> --
> https://code.launchpad.net/~thumper/juju-core/update-loggo/+merge/168342
> Your team juju hackers is requested to review the proposed merge of lp:~thumper/juju-core/update-loggo into lp:juju-core.

Revision history for this message
Tim Penhey (thumper) wrote :

*** Submitted:

Updates for latest loggo.

Since we don't yet have dependency management, the latest
changes to loggo are unpushed until I get this agreed upon.

R=jameinel
CC=
https://codereview.appspot.com/10125046

https://codereview.appspot.com/10125046/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/builddb/main.go'
2--- cmd/builddb/main.go 2013-05-29 05:29:57 +0000
3+++ cmd/builddb/main.go 2013-06-10 04:33:28 +0000
4@@ -57,13 +57,13 @@
5 return err
6 }
7
8- logger.Info("Waiting for unit to reach %q status...", params.StatusStarted)
9+ logger.Infof("Waiting for unit to reach %q status...", params.StatusStarted)
10 unit := units[0]
11 last, info, err := unit.Status()
12 if err != nil {
13 return err
14 }
15- logger.Info("Unit status is %q: %s", last, info)
16+ logger.Infof("Unit status is %q: %s", last, info)
17 for last != params.StatusStarted {
18 time.Sleep(2 * time.Second)
19 if err := unit.Refresh(); err != nil {
20@@ -74,7 +74,7 @@
21 return err
22 }
23 if status != last {
24- logger.Info("Unit status is %q: %s", status, info)
25+ logger.Infof("Unit status is %q: %s", status, info)
26 last = status
27 }
28 }
29@@ -82,7 +82,7 @@
30 if !ok {
31 return fmt.Errorf("cannot retrieve files: build unit lacks a public-address")
32 }
33- logger.Info("Built files published at http://%s", addr)
34- logger.Info("Remember to destroy the environment when you're done...")
35+ logger.Infof("Built files published at http://%s", addr)
36+ logger.Infof("Remember to destroy the environment when you're done...")
37 return nil
38 }
39
40=== modified file 'cmd/juju/main_test.go'
41--- cmd/juju/main_test.go 2013-06-04 21:43:25 +0000
42+++ cmd/juju/main_test.go 2013-06-10 04:33:28 +0000
43@@ -73,7 +73,7 @@
44 }
45
46 func (s *MainSuite) TestTearDown(c *C) {
47- loggo.ResetLogging()
48+ loggo.ResetLoggers()
49 }
50
51 func (s *MainSuite) TestRunMain(c *C) {
52
53=== modified file 'cmd/logging.go'
54--- cmd/logging.go 2013-06-07 01:00:23 +0000
55+++ cmd/logging.go 2013-06-10 04:33:28 +0000
56@@ -57,9 +57,9 @@
57 if l.Debug {
58 level = loggo.DEBUG
59 }
60- logger := loggo.GetLogger("juju")
61- logger.SetLogLevel(level)
62+ // Set the level on the root logger.
63+ loggo.GetLogger("").SetLogLevel(level)
64 }
65- loggo.ConfigureLogging(l.Config)
66+ loggo.ConfigureLoggers(l.Config)
67 return nil
68 }
69
70=== modified file 'cmd/logging_test.go'
71--- cmd/logging_test.go 2013-06-06 03:55:22 +0000
72+++ cmd/logging_test.go 2013-06-10 04:33:28 +0000
73@@ -46,8 +46,7 @@
74 err := l.Start(ctx)
75 c.Assert(err, IsNil)
76
77- logger := loggo.GetLogger("juju")
78- c.Assert(logger.GetLogLevel(), Equals, loggo.INFO)
79+ c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.INFO)
80 }
81
82 func (s *LogSuite) TestDebugSetsLogLevel(c *C) {
83@@ -56,8 +55,7 @@
84 err := l.Start(ctx)
85 c.Assert(err, IsNil)
86
87- logger := loggo.GetLogger("juju")
88- c.Assert(logger.GetLogLevel(), Equals, loggo.DEBUG)
89+ c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.DEBUG)
90 }
91
92 func (s *LogSuite) TestStderr(c *C) {
93
94=== modified file 'log/log.go'
95--- log/log.go 2013-05-30 06:54:40 +0000
96+++ log/log.go 2013-06-10 04:33:28 +0000
97@@ -13,31 +13,31 @@
98
99 // Errorf logs a message using the ERROR priority.
100 func Errorf(format string, a ...interface{}) error {
101- logger.Log(loggo.ERROR, format, a...)
102+ logger.Logf(loggo.ERROR, format, a...)
103 return nil
104 }
105
106 // Warningf logs a message using the WARNING priority.
107 func Warningf(format string, a ...interface{}) error {
108- logger.Log(loggo.WARNING, format, a...)
109+ logger.Logf(loggo.WARNING, format, a...)
110 return nil
111 }
112
113 // Noticef logs a message using the NOTICE priority.
114 // Notice doesn't really convert to the loggo priorities...
115 func Noticef(format string, a ...interface{}) error {
116- logger.Log(loggo.INFO, format, a...)
117+ logger.Logf(loggo.INFO, format, a...)
118 return nil
119 }
120
121 // Infof logs a message using the INFO priority.
122 func Infof(format string, a ...interface{}) error {
123- logger.Log(loggo.INFO, format, a...)
124+ logger.Logf(loggo.INFO, format, a...)
125 return nil
126 }
127
128 // Debugf logs a message using the DEBUG priority.
129 func Debugf(format string, a ...interface{}) (err error) {
130- logger.Log(loggo.DEBUG, format, a...)
131+ logger.Logf(loggo.DEBUG, format, a...)
132 return nil
133 }
134
135=== modified file 'testing/log.go'
136--- testing/log.go 2013-05-31 01:40:31 +0000
137+++ testing/log.go 2013-06-10 04:33:28 +0000
138@@ -32,11 +32,11 @@
139 func (t *LoggingSuite) SetUpTest(c *C) {
140 loggo.ResetWriters()
141 loggo.ReplaceDefaultWriter(&gocheckWriter{c})
142- loggo.ResetLogging()
143+ loggo.ResetLoggers()
144 loggo.GetLogger("juju").SetLogLevel(loggo.DEBUG)
145 }
146
147 func (t *LoggingSuite) TearDownTest(c *C) {
148- loggo.ResetLogging()
149+ loggo.ResetLoggers()
150 loggo.ResetWriters()
151 }
152
153=== modified file 'worker/provisioner/provisioner.go'
154--- worker/provisioner/provisioner.go 2013-06-10 02:52:05 +0000
155+++ worker/provisioner/provisioner.go 2013-06-10 04:33:28 +0000
156@@ -95,14 +95,14 @@
157 return tomb.ErrDying
158 case <-environmentProvisioner.Dying():
159 err := environmentProvisioner.Err()
160- logger.Error("environment provisioner died: %v", err)
161+ logger.Errorf("environment provisioner died: %v", err)
162 return err
163 case cfg, ok := <-environWatcher.Changes():
164 if !ok {
165 return watcher.MustErr(environWatcher)
166 }
167 if err := p.setConfig(cfg); err != nil {
168- logger.Error("loaded invalid environment configuration: %v", err)
169+ logger.Errorf("loaded invalid environment configuration: %v", err)
170 }
171 }
172 }
173
174=== modified file 'worker/provisioner/provisioner_task.go'
175--- worker/provisioner/provisioner_task.go 2013-06-10 02:51:28 +0000
176+++ worker/provisioner/provisioner_task.go 2013-06-10 04:33:28 +0000
177@@ -97,7 +97,7 @@
178 }
179
180 func (task *provisionerTask) loop() error {
181- logger.Info("Starting up provisioner task %s", task.machineId)
182+ logger.Infof("Starting up provisioner task %s", task.machineId)
183 defer watcher.Stop(task.machineWatcher, &task.tomb)
184
185 // When the watcher is started, it will have the initial changes be all
186@@ -106,7 +106,7 @@
187 for {
188 select {
189 case <-task.tomb.Dying():
190- logger.Info("Shutting down provisioner task %s", task.machineId)
191+ logger.Infof("Shutting down provisioner task %s", task.machineId)
192 return tomb.ErrDying
193 case ids, ok := <-task.machineWatcher.Changes():
194 if !ok {
195@@ -115,7 +115,7 @@
196 // TODO(dfc; lp:1042717) fire process machines periodically to shut down unknown
197 // instances.
198 if err := task.processMachines(ids); err != nil {
199- logger.Error("Process machines failed: %v", err)
200+ logger.Errorf("Process machines failed: %v", err)
201 return err
202 }
203 }
204@@ -124,7 +124,7 @@
205 }
206
207 func (task *provisionerTask) processMachines(ids []string) error {
208- logger.Trace("processMachines(%v)", ids)
209+ logger.Tracef("processMachines(%v)", ids)
210 // Populate the tasks maps of current instances and machines.
211 err := task.populateMachineMaps(ids)
212 if err != nil {
213@@ -163,7 +163,7 @@
214
215 instances, err := task.broker.AllInstances()
216 if err != nil {
217- logger.Error("failed to get all instances from broker: %v", err)
218+ logger.Errorf("failed to get all instances from broker: %v", err)
219 return err
220 }
221 for _, i := range instances {
222@@ -177,12 +177,12 @@
223 machine, err := task.machineGetter.Machine(id)
224 switch {
225 case errors.IsNotFoundError(err):
226- logger.Debug("machine %q not found in state", id)
227+ logger.Debugf("machine %q not found in state", id)
228 delete(task.machines, id)
229 case err == nil:
230 task.machines[id] = machine
231 default:
232- logger.Error("failed to get machine: %v", err)
233+ logger.Errorf("failed to get machine: %v", err)
234 }
235 }
236 return nil
237@@ -194,7 +194,7 @@
238 for _, id := range ids {
239 machine, found := task.machines[id]
240 if !found {
241- logger.Info("machine %q not found", id)
242+ logger.Infof("machine %q not found", id)
243 continue
244 }
245 switch machine.Life() {
246@@ -202,17 +202,17 @@
247 if _, ok := machine.InstanceId(); ok {
248 continue
249 }
250- logger.Info("killing dying, unprovisioned machine %q", machine)
251+ logger.Infof("killing dying, unprovisioned machine %q", machine)
252 if err := machine.EnsureDead(); err != nil {
253- logger.Error("failed to ensure machine dead %q: %v", machine, err)
254+ logger.Errorf("failed to ensure machine dead %q: %v", machine, err)
255 return nil, nil, err
256 }
257 fallthrough
258 case state.Dead:
259 dead = append(dead, machine)
260- logger.Info("removing dead machine %q", machine)
261+ logger.Infof("removing dead machine %q", machine)
262 if err := machine.Remove(); err != nil {
263- logger.Error("failed to remove dead machine %q", machine)
264+ logger.Errorf("failed to remove dead machine %q", machine)
265 return nil, nil, err
266 }
267 // now remove it from the machines map
268@@ -222,16 +222,16 @@
269 if instId, hasInstId := machine.InstanceId(); !hasInstId {
270 status, _, err := machine.Status()
271 if err != nil {
272- logger.Info("cannot get machine %q status: %v", machine, err)
273+ logger.Infof("cannot get machine %q status: %v", machine, err)
274 continue
275 }
276 if status == params.StatusPending {
277 pending = append(pending, machine)
278- logger.Info("found machine %q pending provisioning", machine)
279+ logger.Infof("found machine %q pending provisioning", machine)
280 continue
281 }
282 } else {
283- logger.Info("machine %v already started as instance %q", machine, instId)
284+ logger.Infof("machine %v already started as instance %q", machine, instId)
285 }
286 }
287 return
288@@ -254,7 +254,7 @@
289 for _, i := range instances {
290 unknown = append(unknown, i)
291 }
292- logger.Trace("unknown: %v", unknown)
293+ logger.Tracef("unknown: %v", unknown)
294 return unknown, nil
295 }
296
297@@ -282,9 +282,9 @@
298 if len(instances) == 0 {
299 return nil
300 }
301- logger.Debug("Stopping instances: %v", instances)
302+ logger.Debugf("Stopping instances: %v", instances)
303 if err := task.broker.StopInstances(instances); err != nil {
304- logger.Error("broker failed to stop instances: %v", err)
305+ logger.Errorf("broker failed to stop instances: %v", err)
306 return err
307 }
308 return nil
309@@ -306,7 +306,7 @@
310 // state.Info as the PA.
311 stateInfo, apiInfo, err := task.setupAuthentication(machine)
312 if err != nil {
313- logger.Error("failed to setup authentication: %v", err)
314+ logger.Errorf("failed to setup authentication: %v", err)
315 return err
316 }
317 cons, err := machine.Constraints()
318@@ -327,10 +327,10 @@
319 // Set the state to error, so the machine will be skipped next
320 // time until the error is resolved, but don't return an
321 // error; just keep going with the other machines.
322- logger.Error("cannot start instance for machine %q: %v", machine, err)
323+ logger.Errorf("cannot start instance for machine %q: %v", machine, err)
324 if err1 := machine.SetStatus(params.StatusError, err.Error()); err1 != nil {
325 // Something is wrong with this machine, better report it back.
326- logger.Error("cannot set error status for machine %q: %v", machine, err1)
327+ logger.Errorf("cannot set error status for machine %q: %v", machine, err1)
328 return err1
329 }
330 return nil
331@@ -350,7 +350,7 @@
332 // encounter surprising problems.
333 return err
334 }
335- logger.Info("started machine %s as instance %s", machine, inst.Id())
336+ logger.Infof("started machine %s as instance %s", machine, inst.Id())
337 return nil
338 }
339
340
341=== modified file 'worker/uniter/jujuc/juju-log_test.go'
342--- worker/uniter/jujuc/juju-log_test.go 2013-05-30 06:54:40 +0000
343+++ worker/uniter/jujuc/juju-log_test.go 2013-06-10 04:33:28 +0000
344@@ -28,7 +28,7 @@
345 }
346
347 func assertLogs(c *C, ctx jujuc.Context, badge string) {
348- loggo.ConfigureLogging("juju=DEBUG")
349+ loggo.ConfigureLoggers("juju=DEBUG")
350 writer := &loggo.TestWriter{}
351 old_writer, err := loggo.ReplaceDefaultWriter(writer)
352 c.Assert(err, IsNil)

Subscribers

People subscribed via source and target branches