~rogpeppe/juju-core/256-more-status

Viewing all changes in revision 1041.

log: fix data race on log.Target

Many of our test cases set the value of log.Target, then reset it during the test/suite teardown. This has always been racy, but we've worked around it. We're now at the point that it can't be hidden anymore. In this case it is the mgo connection retry logic inside the state tests, but it will always be something.

This proposal makes the setting and getting of log.Target() (actually, log.target.logger) thread safe, and introduces a new nilLogger to make the logic inside each of the logging methods.

There is probably also a race on log.Debug, so a similar proposal will be needed as a followup.

Also, as witnessed by the duplication of logic that sets and resets the log.Target, try to push as much of the log target slight of hand into testing.LoggingSuite.

R=jameinel, dimitern, rog, fwereade, thumper
CC=
https://codereview.appspot.com/7524046

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: