~ubuntu-branches/ubuntu/lucid/bzr/lucid-proposed

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2006-03-20 08:31:00 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060320083100-ovdi2ssuw0epcx8s
Tags: 0.8~200603200831-0ubuntu1
* Snapshot uploaded to Dapper at Martin Pool's request.

* Disable testsuite for upload.  Fakeroot and the testsuite don't
  play along.

Show diffs side-by-side

added added

removed removed

Lines of Context:
219
219
 
220
220
 
221
221
def enable_test_log(to_file):
222
 
    """Redirect logging to a temporary file for a test"""
 
222
    """Redirect logging to a temporary file for a test
 
223
    
 
224
    returns an opaque reference that should be passed to disable_test_log
 
225
    after the test complete.
 
226
    """
223
227
    disable_default_logging()
224
 
    global _test_log_hdlr, _trace_file
 
228
    global _trace_file
225
229
    hdlr = logging.StreamHandler(to_file)
226
230
    hdlr.setLevel(logging.DEBUG)
227
231
    hdlr.setFormatter(logging.Formatter('%(levelname)8s  %(message)s'))
228
232
    _bzr_logger.addHandler(hdlr)
229
233
    _bzr_logger.setLevel(logging.DEBUG)
230
 
    _test_log_hdlr = hdlr
 
234
    result = hdlr, _trace_file
231
235
    _trace_file = to_file
232
 
 
233
 
 
234
 
def disable_test_log():
235
 
    _bzr_logger.removeHandler(_test_log_hdlr)
236
 
    _trace_file = None
 
236
    return result
 
237
 
 
238
 
 
239
def disable_test_log((test_log_hdlr, old_trace_file)):
 
240
    _bzr_logger.removeHandler(test_log_hdlr)
 
241
    _trace_file = old_trace_file
237
242
    enable_default_logging()
238
243
 
239
244