Merge lp:~thumper/juju-core/tweak-logging into lp:~go-bot/juju-core/trunk
- tweak-logging
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1897 |
Proposed branch: | lp:~thumper/juju-core/tweak-logging |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
582 lines (+69/-61) 13 files modified
charm/meta_test.go (+1/-1) environs/config/config.go (+1/-0) environs/config/config_test.go (+5/-5) provider/ec2/config_test.go (+5/-5) provider/local/environprovider.go (+1/-0) provider/openstack/config_test.go (+6/-6) rpc/client.go (+1/-3) rpc/jsoncodec/codec.go (+8/-5) rpc/jsoncodec/codec_test.go (+4/-4) rpc/server.go (+6/-3) schema/schema.go (+1/-1) schema/schema_test.go (+26/-26) worker/environ.go (+4/-2) |
To merge this branch: | bzr merge lp:~thumper/juju-core/tweak-logging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+187953@code.launchpad.net |
Commit message
Tweak internal logging
These are logging changes that happened while debugging
a schema validation failure. Worth keeping IMO.
Description of the change
Tweak internal logging
These are logging changes that happened while debugging
a schema validation failure. Worth keeping IMO.
Tim Penhey (thumper) wrote : | # |
Ian Booth (wallyworld) wrote : | # |
LGTM
https:/
File environs/
https:/
environs/
%v", attrs, checker, err)
Do we need a label in the output for each %v so the reader knows that
they represent? eg attrs: %#v, checker: %#v etc
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~thumper/juju-core/tweak-logging into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
-------
FAIL: meta_test.go:289: MetaSuite.
meta_test.go:314:
c.Assert(err, gc.ErrorMatches, "<path>: expected map, got 42")
... error string = "<path>: expected map, got int(42)"
... regex string = "<path>: expected map, got 42"
OOPS: 77 passed, 1 FAILED
--- FAIL: Test (0.33 seconds)
FAIL
FAIL launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
-------
FAIL: config_test.go:509: ConfigSuite.
test 0. The minimum good configuration
test 1. Metadata URLs
test 2. Explicit series
test 3. Implicit series with empty value
test 4. Explicit authorized-keys
test 5. Load authorized-keys from path
test 6. CA cert & key from path
test 7. CA cert & key from path; cert attribute set too
test 8. CA cert & key from ~ path
test 9. CA cert and key as attributes
test 10. Mismatched CA cert and key
test 11. Invalid CA cert
test 12. Invalid CA key
test 13. CA cert specified as non-existent file
test 14. CA key specified as non-existent file
test 15. Specified agent version
test 16. Specified development flag
test 17. Specified admin secret
test 18. Invalid development flag
config_test.go:528:
test.check(c, h)
config_test.go:634:
c.Assert(err, gc.ErrorMatches, test.err)
... error string = "development: expected bool, got string(\"true\")"
... regex string = "development: expected bool, got \"true\""
-------
FAIL: config_test.go:873: ConfigSuite.
[LOG] 36.01435 WARNING juju.environs.
[LOG] 36.01439 WARNING juju.environs.
[LOG] 36.01443 WARNING juju.environs.
[LOG] 36.01446 WARNING juju.environs.
[LOG] 36.01452 ERROR juju.environs.
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~thumper/juju-core/tweak-logging into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
-------
FAIL: meta_test.go:289: MetaSuite.
meta_test.go:314:
c.Assert(err, gc.ErrorMatches, "<path>: expected map, got 42")
... error string = "<path>: expected map, got int(42)"
... regex string = "<path>: expected map, got 42"
OOPS: 77 passed, 1 FAILED
--- FAIL: Test (0.32 seconds)
FAIL
FAIL launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
-------
FAIL: config_test.go:509: ConfigSuite.
test 0. The minimum good configuration
test 1. Metadata URLs
test 2. Explicit series
test 3. Implicit series with empty value
test 4. Explicit authorized-keys
test 5. Load authorized-keys from path
test 6. CA cert & key from path
test 7. CA cert & key from path; cert attribute set too
test 8. CA cert & key from ~ path
test 9. CA cert and key as attributes
test 10. Mismatched CA cert and key
test 11. Invalid CA cert
test 12. Invalid CA key
test 13. CA cert specified as non-existent file
test 14. CA key specified as non-existent file
test 15. Specified agent version
test 16. Specified development flag
test 17. Specified admin secret
test 18. Invalid development flag
config_test.go:528:
test.check(c, h)
config_test.go:634:
c.Assert(err, gc.ErrorMatches, test.err)
... error string = "development: expected bool, got string(\"true\")"
... regex string = "development: expected bool, got \"true\""
-------
FAIL: config_test.go:873: ConfigSuite.
[LOG] 49.85043 WARNING juju.environs.
[LOG] 49.85046 WARNING juju.environs.
[LOG] 49.85049 WARNING juju.environs.
[LOG] 49.85052 WARNING juju.environs.
[LOG] 49.85058 ERROR juju.environs.
Preview Diff
1 | === modified file 'charm/meta_test.go' |
2 | --- charm/meta_test.go 2013-08-19 11:17:19 +0000 |
3 | +++ charm/meta_test.go 2013-09-27 02:03:51 +0000 |
4 | @@ -311,7 +311,7 @@ |
5 | |
6 | // Invalid data raises an error. |
7 | v, err = e.Coerce(42, path) |
8 | - c.Assert(err, gc.ErrorMatches, "<path>: expected map, got 42") |
9 | + c.Assert(err, gc.ErrorMatches, `<path>: expected map, got int\(42\)`) |
10 | |
11 | v, err = e.Coerce(map[string]interface{}{"interface": "http", "optional": nil}, path) |
12 | c.Assert(err, gc.ErrorMatches, "<path>.optional: expected bool, got nothing") |
13 | |
14 | === modified file 'environs/config/config.go' |
15 | --- environs/config/config.go 2013-09-24 05:42:43 +0000 |
16 | +++ environs/config/config.go 2013-09-27 02:03:51 +0000 |
17 | @@ -587,6 +587,7 @@ |
18 | checker := schema.FieldMap(fields, defaults) |
19 | coerced, err := checker.Coerce(attrs, nil) |
20 | if err != nil { |
21 | + logger.Errorf("coersion failed attributes: %#v, checker: %#v, %v", attrs, checker, err) |
22 | return nil, err |
23 | } |
24 | result := coerced.(map[string]interface{}) |
25 | |
26 | === modified file 'environs/config/config_test.go' |
27 | --- environs/config/config_test.go 2013-09-20 02:33:04 +0000 |
28 | +++ environs/config/config_test.go 2013-09-27 02:03:51 +0000 |
29 | @@ -273,7 +273,7 @@ |
30 | "authorized-keys": "my-keys", |
31 | "development": "true", |
32 | }, |
33 | - err: "development: expected bool, got \"true\"", |
34 | + err: `development: expected bool, got string\("true"\)`, |
35 | }, { |
36 | about: "Invalid agent version", |
37 | useDefaults: config.UseDefaults, |
38 | @@ -386,7 +386,7 @@ |
39 | "name": "my-name", |
40 | "ssl-hostname-verification": "yes please", |
41 | }, |
42 | - err: `ssl-hostname-verification: expected bool, got "yes please"`, |
43 | + err: `ssl-hostname-verification: expected bool, got string\("yes please"\)`, |
44 | }, { |
45 | about: "Explicit state port", |
46 | useDefaults: config.UseDefaults, |
47 | @@ -403,7 +403,7 @@ |
48 | "name": "my-name", |
49 | "state-port": "illegal", |
50 | }, |
51 | - err: `state-port: expected number, got "illegal"`, |
52 | + err: `state-port: expected number, got string\("illegal"\)`, |
53 | }, { |
54 | about: "Explicit API port", |
55 | useDefaults: config.UseDefaults, |
56 | @@ -420,7 +420,7 @@ |
57 | "name": "my-name", |
58 | "api-port": "illegal", |
59 | }, |
60 | - err: `api-port: expected number, got "illegal"`, |
61 | + err: `api-port: expected number, got string\("illegal"\)`, |
62 | }, { |
63 | about: "Invalid logging configuration", |
64 | useDefaults: config.UseDefaults, |
65 | @@ -910,7 +910,7 @@ |
66 | // Invalid field: failure. |
67 | fields["known"] = schema.Int() |
68 | _, err = cfg.ValidateUnknownAttrs(fields, defaults) |
69 | - c.Assert(err, gc.ErrorMatches, `known: expected int, got "this"`) |
70 | + c.Assert(err, gc.ErrorMatches, `known: expected int, got string\("this"\)`) |
71 | } |
72 | |
73 | func newTestConfig(c *gc.C, explicit testing.Attrs) *config.Config { |
74 | |
75 | === modified file 'provider/ec2/config_test.go' |
76 | --- provider/ec2/config_test.go 2013-09-25 17:04:52 +0000 |
77 | +++ provider/ec2/config_test.go 2013-09-27 02:03:51 +0000 |
78 | @@ -161,22 +161,22 @@ |
79 | config: attrs{ |
80 | "region": 666, |
81 | }, |
82 | - err: ".*expected string, got 666", |
83 | + err: `.*expected string, got int\(666\)`, |
84 | }, { |
85 | config: attrs{ |
86 | "access-key": 666, |
87 | }, |
88 | - err: ".*expected string, got 666", |
89 | + err: `.*expected string, got int\(666\)`, |
90 | }, { |
91 | config: attrs{ |
92 | "secret-key": 666, |
93 | }, |
94 | - err: ".*expected string, got 666", |
95 | + err: `.*expected string, got int\(666\)`, |
96 | }, { |
97 | config: attrs{ |
98 | "control-bucket": 666, |
99 | }, |
100 | - err: ".*expected string, got 666", |
101 | + err: `.*expected string, got int\(666\)`, |
102 | }, { |
103 | change: attrs{ |
104 | "control-bucket": "new-x", |
105 | @@ -186,7 +186,7 @@ |
106 | config: attrs{ |
107 | "public-bucket": 666, |
108 | }, |
109 | - err: ".*expected string, got 666", |
110 | + err: `.*expected string, got int\(666\)`, |
111 | }, { |
112 | // check that the public-bucket defaults to juju-dist |
113 | config: attrs{}, |
114 | |
115 | === modified file 'provider/local/environprovider.go' |
116 | --- provider/local/environprovider.go 2013-09-25 17:30:09 +0000 |
117 | +++ provider/local/environprovider.go 2013-09-27 02:03:51 +0000 |
118 | @@ -65,6 +65,7 @@ |
119 | } |
120 | validated, err := cfg.ValidateUnknownAttrs(configFields, configDefaults) |
121 | if err != nil { |
122 | + logger.Errorf("failed to validate unknown attrs: %v", err) |
123 | return nil, err |
124 | } |
125 | localConfig := newEnvironConfig(cfg, validated) |
126 | |
127 | === modified file 'provider/openstack/config_test.go' |
128 | --- provider/openstack/config_test.go 2013-09-25 17:30:09 +0000 |
129 | +++ provider/openstack/config_test.go 2013-09-27 02:03:51 +0000 |
130 | @@ -219,7 +219,7 @@ |
131 | config: attrs{ |
132 | "region": 666, |
133 | }, |
134 | - err: ".*expected string, got 666", |
135 | + err: `.*expected string, got int\(666\)`, |
136 | }, { |
137 | summary: "missing region in environment", |
138 | envVars: map[string]string{ |
139 | @@ -232,7 +232,7 @@ |
140 | config: attrs{ |
141 | "username": 666, |
142 | }, |
143 | - err: ".*expected string, got 666", |
144 | + err: `.*expected string, got int\(666\)`, |
145 | }, { |
146 | summary: "missing username in environment", |
147 | err: "required environment variable not set for credentials attribute: User", |
148 | @@ -245,7 +245,7 @@ |
149 | config: attrs{ |
150 | "password": 666, |
151 | }, |
152 | - err: ".*expected string, got 666", |
153 | + err: `.*expected string, got int\(666\)`, |
154 | }, { |
155 | summary: "missing password in environment", |
156 | err: "required environment variable not set for credentials attribute: Secrets", |
157 | @@ -258,7 +258,7 @@ |
158 | config: attrs{ |
159 | "tenant-name": 666, |
160 | }, |
161 | - err: ".*expected string, got 666", |
162 | + err: `.*expected string, got int\(666\)`, |
163 | }, { |
164 | summary: "missing tenant in environment", |
165 | err: "required environment variable not set for credentials attribute: TenantName", |
166 | @@ -271,7 +271,7 @@ |
167 | config: attrs{ |
168 | "auth-url": 666, |
169 | }, |
170 | - err: ".*expected string, got 666", |
171 | + err: `.*expected string, got int\(666\)`, |
172 | }, { |
173 | summary: "missing auth-url in environment", |
174 | err: "required environment variable not set for credentials attribute: URL", |
175 | @@ -325,7 +325,7 @@ |
176 | config: attrs{ |
177 | "control-bucket": 666, |
178 | }, |
179 | - err: ".*expected string, got 666", |
180 | + err: `.*expected string, got int\(666\)`, |
181 | }, { |
182 | summary: "changing control-bucket", |
183 | change: attrs{ |
184 | |
185 | === modified file 'rpc/client.go' |
186 | --- rpc/client.go 2013-07-09 10:32:23 +0000 |
187 | +++ rpc/client.go 2013-09-27 02:03:51 +0000 |
188 | @@ -5,8 +5,6 @@ |
189 | |
190 | import ( |
191 | "errors" |
192 | - |
193 | - "launchpad.net/juju-core/log" |
194 | ) |
195 | |
196 | var ErrShutdown = errors.New("connection is shut down") |
197 | @@ -123,7 +121,7 @@ |
198 | default: |
199 | // We don't want to block here. It is the caller's responsibility to make |
200 | // sure the channel has enough buffer space. See comment in Go(). |
201 | - log.Errorf("rpc: discarding Call reply due to insufficient Done chan capacity") |
202 | + logger.Errorf("discarding Call reply due to insufficient Done chan capacity") |
203 | } |
204 | } |
205 | |
206 | |
207 | === modified file 'rpc/jsoncodec/codec.go' |
208 | --- rpc/jsoncodec/codec.go 2013-09-13 14:48:13 +0000 |
209 | +++ rpc/jsoncodec/codec.go 2013-09-27 02:03:51 +0000 |
210 | @@ -8,10 +8,13 @@ |
211 | "sync" |
212 | "sync/atomic" |
213 | |
214 | - "launchpad.net/juju-core/log" |
215 | + "launchpad.net/loggo" |
216 | + |
217 | "launchpad.net/juju-core/rpc" |
218 | ) |
219 | |
220 | +var logger = loggo.GetLogger("juju.rpc.jsoncodec") |
221 | + |
222 | // JSONConn sends and receives messages to an underlying connection |
223 | // in JSON format. |
224 | type JSONConn interface { |
225 | @@ -101,10 +104,10 @@ |
226 | var m json.RawMessage |
227 | err = c.conn.Receive(&m) |
228 | if err == nil { |
229 | - log.Debugf("rpc/jsoncodec: <- %s", m) |
230 | + logger.Debugf("<- %s", m) |
231 | err = json.Unmarshal(m, &c.msg) |
232 | } else { |
233 | - log.Debugf("rpc/jsoncodec: <- error: %v (closing %v)", err, c.isClosing()) |
234 | + logger.Debugf("<- error: %v (closing %v)", err, c.isClosing()) |
235 | } |
236 | } else { |
237 | err = c.conn.Receive(&c.msg) |
238 | @@ -163,10 +166,10 @@ |
239 | if c.isLogging() { |
240 | data, err := json.Marshal(r) |
241 | if err != nil { |
242 | - log.Debugf("rpc/jsoncodec: -> marshal error: %v", err) |
243 | + logger.Debugf("-> marshal error: %v", err) |
244 | return err |
245 | } |
246 | - log.Debugf("rpc/jsoncodec: -> %s", data) |
247 | + logger.Debugf("-> %s", data) |
248 | } |
249 | return c.conn.Send(r) |
250 | } |
251 | |
252 | === modified file 'rpc/jsoncodec/codec_test.go' |
253 | --- rpc/jsoncodec/codec_test.go 2013-09-20 02:53:59 +0000 |
254 | +++ rpc/jsoncodec/codec_test.go 2013-09-27 02:03:51 +0000 |
255 | @@ -96,13 +96,13 @@ |
256 | codec.SetLogging(true) |
257 | err = codec.ReadHeader(&h) |
258 | c.Assert(err, gc.IsNil) |
259 | - c.Assert(c.GetTestLog(), gc.Matches, ".*DEBUG juju rpc/jsoncodec: <- "+regexp.QuoteMeta(msg)+`\n`) |
260 | + c.Assert(c.GetTestLog(), gc.Matches, ".*DEBUG juju.rpc.jsoncodec <- "+regexp.QuoteMeta(msg)+`\n`) |
261 | |
262 | // Check that we can switch it off again |
263 | codec.SetLogging(false) |
264 | err = codec.ReadHeader(&h) |
265 | c.Assert(err, gc.IsNil) |
266 | - c.Assert(c.GetTestLog(), gc.Matches, ".*DEBUG juju rpc/jsoncodec: <- "+regexp.QuoteMeta(msg)+`\n`) |
267 | + c.Assert(c.GetTestLog(), gc.Matches, ".*DEBUG juju.rpc.jsoncodec <- "+regexp.QuoteMeta(msg)+`\n`) |
268 | } |
269 | |
270 | func (*suite) TestWriteMessageLogsRequests(c *gc.C) { |
271 | @@ -124,13 +124,13 @@ |
272 | err = codec.WriteMessage(&h, value{X: "param"}) |
273 | c.Assert(err, gc.IsNil) |
274 | msg := `{"RequestId":1,"Type":"foo","Id":"id","Request":"frob","Params":{"X":"param"}}` |
275 | - c.Assert(c.GetTestLog(), gc.Matches, `.*DEBUG juju rpc/jsoncodec: -> `+regexp.QuoteMeta(msg)+`\n`) |
276 | + c.Assert(c.GetTestLog(), gc.Matches, `.*DEBUG juju.rpc.jsoncodec -> `+regexp.QuoteMeta(msg)+`\n`) |
277 | |
278 | // Check that we can switch it off again |
279 | codec.SetLogging(false) |
280 | err = codec.WriteMessage(&h, value{X: "param"}) |
281 | c.Assert(err, gc.IsNil) |
282 | - c.Assert(c.GetTestLog(), gc.Matches, `.*DEBUG juju rpc/jsoncodec: -> `+regexp.QuoteMeta(msg)+`\n`) |
283 | + c.Assert(c.GetTestLog(), gc.Matches, `.*DEBUG juju.rpc.jsoncodec -> `+regexp.QuoteMeta(msg)+`\n`) |
284 | } |
285 | |
286 | func (*suite) TestConcurrentSetLoggingAndWrite(c *gc.C) { |
287 | |
288 | === modified file 'rpc/server.go' |
289 | --- rpc/server.go 2013-09-22 19:18:03 +0000 |
290 | +++ rpc/server.go 2013-09-27 02:03:51 +0000 |
291 | @@ -9,10 +9,13 @@ |
292 | "reflect" |
293 | "sync" |
294 | |
295 | - "launchpad.net/juju-core/log" |
296 | + "launchpad.net/loggo" |
297 | + |
298 | "launchpad.net/juju-core/rpc/rpcreflect" |
299 | ) |
300 | |
301 | +var logger = loggo.GetLogger("juju.rpc") |
302 | + |
303 | // A Codec implements reading and writing of messages in an RPC |
304 | // session. The RPC code calls WriteMessage to write a message to the |
305 | // connection and calls ReadHeader and ReadBody in pairs to read |
306 | @@ -231,7 +234,7 @@ |
307 | |
308 | // Closing the codec should cause the input loop to terminate. |
309 | if err := conn.codec.Close(); err != nil { |
310 | - log.Infof("rpc: error closing codec: %v", err) |
311 | + logger.Infof("error closing codec: %v", err) |
312 | } |
313 | <-conn.dead |
314 | return conn.inputLoopError |
315 | @@ -412,6 +415,6 @@ |
316 | err = conn.codec.WriteMessage(hdr, rvi) |
317 | } |
318 | if err != nil { |
319 | - log.Errorf("rpc: error writing response: %v", err) |
320 | + logger.Errorf("error writing response: %v", err) |
321 | } |
322 | } |
323 | |
324 | === modified file 'schema/schema.go' |
325 | --- schema/schema.go 2013-05-29 13:09:16 +0000 |
326 | +++ schema/schema.go 2013-09-27 02:03:51 +0000 |
327 | @@ -40,7 +40,7 @@ |
328 | if e.got == nil { |
329 | return fmt.Sprintf("%s: expected %s, got nothing", path, e.want) |
330 | } |
331 | - return fmt.Sprintf("%s: expected %s, got %#v", path, e.want, e.got) |
332 | + return fmt.Sprintf("%s: expected %s, got %T(%#v)", path, e.want, e.got, e.got) |
333 | } |
334 | |
335 | // Any returns a Checker that succeeds with any input value and |
336 | |
337 | === modified file 'schema/schema_test.go' |
338 | --- schema/schema_test.go 2013-08-19 11:20:02 +0000 |
339 | +++ schema/schema_test.go 2013-09-27 02:03:51 +0000 |
340 | @@ -37,7 +37,7 @@ |
341 | |
342 | out, err = sch.Coerce(42, aPath) |
343 | c.Assert(out, gc.IsNil) |
344 | - c.Assert(err, gc.ErrorMatches, `<path>: expected "foo", got 42`) |
345 | + c.Assert(err, gc.ErrorMatches, `<path>: expected "foo", got int\(42\)`) |
346 | |
347 | out, err = sch.Coerce(nil, aPath) |
348 | c.Assert(out, gc.IsNil) |
349 | @@ -85,7 +85,7 @@ |
350 | |
351 | out, err = sch.Coerce(1, aPath) |
352 | c.Assert(out, gc.IsNil) |
353 | - c.Assert(err, gc.ErrorMatches, "<path>: expected bool, got 1") |
354 | + c.Assert(err, gc.ErrorMatches, `<path>: expected bool, got int\(1\)`) |
355 | |
356 | out, err = sch.Coerce(nil, aPath) |
357 | c.Assert(out, gc.IsNil) |
358 | @@ -105,7 +105,7 @@ |
359 | |
360 | out, err = sch.Coerce(true, aPath) |
361 | c.Assert(out, gc.IsNil) |
362 | - c.Assert(err, gc.ErrorMatches, "<path>: expected int, got true") |
363 | + c.Assert(err, gc.ErrorMatches, `<path>: expected int, got bool\(true\)`) |
364 | |
365 | out, err = sch.Coerce(nil, aPath) |
366 | c.Assert(out, gc.IsNil) |
367 | @@ -142,7 +142,7 @@ |
368 | |
369 | out, err = sch.Coerce(true, aPath) |
370 | c.Assert(out, gc.IsNil) |
371 | - c.Assert(err, gc.ErrorMatches, "<path>: expected number, got true") |
372 | + c.Assert(err, gc.ErrorMatches, `<path>: expected number, got bool\(true\)`) |
373 | |
374 | out, err = sch.Coerce(nil, aPath) |
375 | c.Assert(out, gc.IsNil) |
376 | @@ -162,7 +162,7 @@ |
377 | |
378 | out, err = sch.Coerce(true, aPath) |
379 | c.Assert(out, gc.IsNil) |
380 | - c.Assert(err, gc.ErrorMatches, "<path>: expected float, got true") |
381 | + c.Assert(err, gc.ErrorMatches, `<path>: expected float, got bool\(true\)`) |
382 | |
383 | out, err = sch.Coerce(nil, aPath) |
384 | c.Assert(out, gc.IsNil) |
385 | @@ -178,7 +178,7 @@ |
386 | |
387 | out, err = sch.Coerce(true, aPath) |
388 | c.Assert(out, gc.IsNil) |
389 | - c.Assert(err, gc.ErrorMatches, "<path>: expected string, got true") |
390 | + c.Assert(err, gc.ErrorMatches, `<path>: expected string, got bool\(true\)`) |
391 | |
392 | out, err = sch.Coerce(nil, aPath) |
393 | c.Assert(out, gc.IsNil) |
394 | @@ -193,11 +193,11 @@ |
395 | |
396 | out, err = sch.Coerce(1, aPath) |
397 | c.Assert(out, gc.IsNil) |
398 | - c.Assert(err, gc.ErrorMatches, "<path>: expected regexp string, got 1") |
399 | + c.Assert(err, gc.ErrorMatches, `<path>: expected regexp string, got int\(1\)`) |
400 | |
401 | out, err = sch.Coerce("[", aPath) |
402 | c.Assert(out, gc.IsNil) |
403 | - c.Assert(err, gc.ErrorMatches, `<path>: expected valid regexp, got "\["`) |
404 | + c.Assert(err, gc.ErrorMatches, `<path>: expected valid regexp, got string\("\["\)`) |
405 | |
406 | out, err = sch.Coerce(nil, aPath) |
407 | c.Assert(out, gc.IsNil) |
408 | @@ -212,7 +212,7 @@ |
409 | |
410 | out, err = sch.Coerce(42, aPath) |
411 | c.Assert(out, gc.IsNil) |
412 | - c.Assert(err, gc.ErrorMatches, "<path>: expected list, got 42") |
413 | + c.Assert(err, gc.ErrorMatches, "<path>: expected list, got int\\(42\\)") |
414 | |
415 | out, err = sch.Coerce(nil, aPath) |
416 | c.Assert(out, gc.IsNil) |
417 | @@ -220,7 +220,7 @@ |
418 | |
419 | out, err = sch.Coerce([]interface{}{1, true}, aPath) |
420 | c.Assert(out, gc.IsNil) |
421 | - c.Assert(err, gc.ErrorMatches, `<path>\[1\]: expected int, got true`) |
422 | + c.Assert(err, gc.ErrorMatches, `<path>\[1\]: expected int, got bool\(true\)`) |
423 | } |
424 | |
425 | func (s *S) TestMap(c *gc.C) { |
426 | @@ -231,7 +231,7 @@ |
427 | |
428 | out, err = sch.Coerce(42, aPath) |
429 | c.Assert(out, gc.IsNil) |
430 | - c.Assert(err, gc.ErrorMatches, "<path>: expected map, got 42") |
431 | + c.Assert(err, gc.ErrorMatches, "<path>: expected map, got int\\(42\\)") |
432 | |
433 | out, err = sch.Coerce(nil, aPath) |
434 | c.Assert(out, gc.IsNil) |
435 | @@ -239,16 +239,16 @@ |
436 | |
437 | out, err = sch.Coerce(map[int]int{1: 1}, aPath) |
438 | c.Assert(out, gc.IsNil) |
439 | - c.Assert(err, gc.ErrorMatches, "<path>: expected string, got 1") |
440 | + c.Assert(err, gc.ErrorMatches, "<path>: expected string, got int\\(1\\)") |
441 | |
442 | out, err = sch.Coerce(map[string]bool{"a": true}, aPath) |
443 | c.Assert(out, gc.IsNil) |
444 | - c.Assert(err, gc.ErrorMatches, `<path>\.a: expected int, got true`) |
445 | + c.Assert(err, gc.ErrorMatches, `<path>\.a: expected int, got bool\(true\)`) |
446 | |
447 | // First path entry shouldn't have dots in an error message. |
448 | out, err = sch.Coerce(map[string]bool{"a": true}, nil) |
449 | c.Assert(out, gc.IsNil) |
450 | - c.Assert(err, gc.ErrorMatches, `a: expected int, got true`) |
451 | + c.Assert(err, gc.ErrorMatches, `a: expected int, got bool\(true\)`) |
452 | } |
453 | |
454 | func (s *S) TestStringMap(c *gc.C) { |
455 | @@ -259,7 +259,7 @@ |
456 | |
457 | out, err = sch.Coerce(42, aPath) |
458 | c.Assert(out, gc.IsNil) |
459 | - c.Assert(err, gc.ErrorMatches, "<path>: expected map, got 42") |
460 | + c.Assert(err, gc.ErrorMatches, "<path>: expected map, got int\\(42\\)") |
461 | |
462 | out, err = sch.Coerce(nil, aPath) |
463 | c.Assert(out, gc.IsNil) |
464 | @@ -267,16 +267,16 @@ |
465 | |
466 | out, err = sch.Coerce(map[int]int{1: 1}, aPath) |
467 | c.Assert(out, gc.IsNil) |
468 | - c.Assert(err, gc.ErrorMatches, "<path>: expected string, got 1") |
469 | + c.Assert(err, gc.ErrorMatches, "<path>: expected string, got int\\(1\\)") |
470 | |
471 | out, err = sch.Coerce(map[string]bool{"a": true}, aPath) |
472 | c.Assert(out, gc.IsNil) |
473 | - c.Assert(err, gc.ErrorMatches, `<path>\.a: expected int, got true`) |
474 | + c.Assert(err, gc.ErrorMatches, `<path>\.a: expected int, got bool\(true\)`) |
475 | |
476 | // First path entry shouldn't have dots in an error message. |
477 | out, err = sch.Coerce(map[string]bool{"a": true}, nil) |
478 | c.Assert(out, gc.IsNil) |
479 | - c.Assert(err, gc.ErrorMatches, `a: expected int, got true`) |
480 | + c.Assert(err, gc.ErrorMatches, `a: expected int, got bool\(true\)`) |
481 | } |
482 | |
483 | func assertFieldMap(c *gc.C, sch schema.Checker) { |
484 | @@ -287,7 +287,7 @@ |
485 | |
486 | out, err = sch.Coerce(42, aPath) |
487 | c.Assert(out, gc.IsNil) |
488 | - c.Assert(err, gc.ErrorMatches, "<path>: expected map, got 42") |
489 | + c.Assert(err, gc.ErrorMatches, "<path>: expected map, got int\\(42\\)") |
490 | |
491 | out, err = sch.Coerce(nil, aPath) |
492 | c.Assert(out, gc.IsNil) |
493 | @@ -295,7 +295,7 @@ |
494 | |
495 | out, err = sch.Coerce(map[string]interface{}{"a": "A", "b": "C"}, aPath) |
496 | c.Assert(out, gc.IsNil) |
497 | - c.Assert(err, gc.ErrorMatches, `<path>\.b: expected "B", got "C"`) |
498 | + c.Assert(err, gc.ErrorMatches, `<path>\.b: expected "B", got string\("C"\)`) |
499 | |
500 | out, err = sch.Coerce(map[string]interface{}{"b": "B"}, aPath) |
501 | c.Assert(out, gc.IsNil) |
502 | @@ -309,7 +309,7 @@ |
503 | // First path entry shouldn't have dots in an error message. |
504 | out, err = sch.Coerce(map[string]bool{"a": true}, nil) |
505 | c.Assert(out, gc.IsNil) |
506 | - c.Assert(err, gc.ErrorMatches, `a: expected "A", got true`) |
507 | + c.Assert(err, gc.ErrorMatches, `a: expected "A", got bool\(true\)`) |
508 | } |
509 | |
510 | func (s *S) TestFieldMap(c *gc.C) { |
511 | @@ -343,7 +343,7 @@ |
512 | } |
513 | sch := schema.FieldMap(fields, defaults) |
514 | _, err := sch.Coerce(map[string]interface{}{}, aPath) |
515 | - c.Assert(err, gc.ErrorMatches, `<path>.a: expected "A", got "B"`) |
516 | + c.Assert(err, gc.ErrorMatches, `<path>.a: expected "A", got string\("B"\)`) |
517 | } |
518 | |
519 | func (s *S) TestStrictFieldMap(c *gc.C) { |
520 | @@ -361,7 +361,7 @@ |
521 | |
522 | out, err := sch.Coerce(map[string]interface{}{"a": "A", "b": "B", "d": "D"}, aPath) |
523 | c.Assert(out, gc.IsNil) |
524 | - c.Assert(err, gc.ErrorMatches, `<path>.d: expected nothing, got "D"`) |
525 | + c.Assert(err, gc.ErrorMatches, `<path>.d: expected nothing, got string\("D"\)`) |
526 | } |
527 | |
528 | func (s *S) TestSchemaMap(c *gc.C) { |
529 | @@ -389,15 +389,15 @@ |
530 | |
531 | out, err = sch.Coerce(map[string]int{"type": 2}, aPath) |
532 | c.Assert(out, gc.IsNil) |
533 | - c.Assert(err, gc.ErrorMatches, `<path>\.type: expected supported selector, got 2`) |
534 | + c.Assert(err, gc.ErrorMatches, `<path>\.type: expected supported selector, got int\(2\)`) |
535 | |
536 | out, err = sch.Coerce(map[string]int{"type": 3, "b": 5}, aPath) |
537 | c.Assert(out, gc.IsNil) |
538 | - c.Assert(err, gc.ErrorMatches, `<path>\.b: expected 4, got 5`) |
539 | + c.Assert(err, gc.ErrorMatches, `<path>\.b: expected 4, got int\(5\)`) |
540 | |
541 | out, err = sch.Coerce(42, aPath) |
542 | c.Assert(out, gc.IsNil) |
543 | - c.Assert(err, gc.ErrorMatches, `<path>: expected map, got 42`) |
544 | + c.Assert(err, gc.ErrorMatches, `<path>: expected map, got int\(42\)`) |
545 | |
546 | out, err = sch.Coerce(nil, aPath) |
547 | c.Assert(out, gc.IsNil) |
548 | |
549 | === modified file 'worker/environ.go' |
550 | --- worker/environ.go 2013-09-25 15:27:42 +0000 |
551 | +++ worker/environ.go 2013-09-27 02:03:51 +0000 |
552 | @@ -6,11 +6,11 @@ |
553 | import ( |
554 | "errors" |
555 | |
556 | + "launchpad.net/loggo" |
557 | "launchpad.net/tomb" |
558 | |
559 | "launchpad.net/juju-core/environs" |
560 | "launchpad.net/juju-core/environs/config" |
561 | - "launchpad.net/juju-core/log" |
562 | apiwatcher "launchpad.net/juju-core/state/api/watcher" |
563 | "launchpad.net/juju-core/state/watcher" |
564 | ) |
565 | @@ -19,6 +19,8 @@ |
566 | |
567 | var loadedInvalid = func() {} |
568 | |
569 | +var logger = loggo.GetLogger("juju.worker") |
570 | + |
571 | // EnvironConfigGetter interface defines a way to read the environment |
572 | // configuration. |
573 | type EnvironConfigGetter interface { |
574 | @@ -45,7 +47,7 @@ |
575 | if err == nil { |
576 | return environ, nil |
577 | } |
578 | - log.Errorf("worker: loaded invalid environment configuration: %v", err) |
579 | + logger.Errorf("loaded invalid environment configuration: %v", err) |
580 | loadedInvalid() |
581 | } |
582 | } |
Reviewers: mp+187953_ code.launchpad. net,
Message:
Please take a look.
Description:
Tweak internal logging
These are logging changes that happend while debugging
a schema validation failure. Worth keeping IMO.
https:/ /code.launchpad .net/~thumper/ juju-core/ tweak-logging/ +merge/ 187953
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/14005043/
Affected files (+24, -14 lines): config/ config. go local/environpr ovider. go codec.go
A [revision details]
M environs/
M provider/
M rpc/client.go
M rpc/jsoncodec/
M rpc/server.go
M schema/schema.go
M worker/environ.go
Index: [revision details] 20130926184157- 5d305cr4rb895ln t
=== 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-
+New revision: <email address hidden>
Index: rpc/client.go
=== modified file 'rpc/client.go'
--- rpc/client.go 2013-07-09 10:32:23 +0000
+++ rpc/client.go 2013-09-26 22:50:09 +0000
@@ -5,8 +5,6 @@
import ( net/juju- core/log"
"errors"
-
- "launchpad.
)
var ErrShutdown = errors. New("connection is shut down") Errorf( "discarding Call reply due to insufficient Done chan
@@ -123,7 +121,7 @@
default:
// We don't want to block here. It is the caller's responsibility to
make
// sure the channel has enough buffer space. See comment in Go().
- log.Errorf("rpc: discarding Call reply due to insufficient Done chan
capacity")
+ logger.
capacity")
}
}
Index: rpc/server.go
=== modified file 'rpc/server.go'
--- rpc/server.go 2013-09-22 19:18:03 +0000
+++ rpc/server.go 2013-09-26 22:49:37 +0000
@@ -9,10 +9,13 @@
"reflect"
"sync"
- "launchpad. net/juju- core/log" net/loggo" net/juju- core/rpc/ rpcreflect"
+ "launchpad.
+
"launchpad.
)
+var logger = loggo.GetLogger ("juju. rpc")
+
// A Codec implements reading and writing of messages in an RPC
// session. The RPC code calls WriteMessage to write a message to the
// connection and calls ReadHeader and ReadBody in pairs to read
@@ -231,7 +234,7 @@
// Closing the codec should cause the input loop to terminate. WriteMessage( hdr, rvi) Errorf( "error writing response: %v", err)
if err := conn.codec.Close(); err != nil {
- log.Infof("rpc: error closing codec: %v", err)
+ logger.Infof("error closing codec: %v", err)
}
<-conn.dead
return conn.inputLoopError
@@ -412,6 +415,6 @@
err = conn.codec.
}
if err != nil {
- log.Errorf("rpc: error writing response: %v", err)
+ logger.
}
}
Index: schema/schema.go
=== modified file 'schema/schema.go'
--- schema/schema.go 2013-05-29 13:09:16 +0000
+++ schema/schema.go 2013-09-26 23:26:19 +0000
@@ -40,7 +40,7 @@
if e.got == nil {
return fmt.Sprintf("%s: expected %s, got nothing", path, e.want)
}
- return fmt.Sprintf("%s: expected %s, got %#v", path, e.want, e.got)
+ return fmt.Sprintf("%s: expected %s, got %T(%#v)", path, e.want, e.got,
e.got)
}
// Any returns a Checker that succeeds with any input value and
Index: environs/ config/ config. go config/ config. go'
=== modified file 'environs/
--- enviro...