~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-11 17:50:37 UTC
  • mfrom: (1704.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060511175037-f66b84c6a9fc4c12
Merge selftest uses progress-bars. (Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
_stderr_handler = None
53
53
_stderr_quiet = False
54
54
_trace_file = None
 
55
_trace_depth = 0
55
56
_bzr_log_file = None
56
57
 
57
58
 
231
232
    """Redirect logging to a temporary file for a test
232
233
    
233
234
    returns an opaque reference that should be passed to disable_test_log
234
 
    after the test complete.
 
235
    after the test completes.
235
236
    """
236
237
    disable_default_logging()
237
238
    global _trace_file
 
239
    global _trace_depth
238
240
    hdlr = logging.StreamHandler(to_file)
239
241
    hdlr.setLevel(logging.DEBUG)
240
242
    hdlr.setFormatter(logging.Formatter('%(levelname)8s  %(message)s'))
241
243
    _bzr_logger.addHandler(hdlr)
242
244
    _bzr_logger.setLevel(logging.DEBUG)
243
 
    result = hdlr, _trace_file
 
245
    result = hdlr, _trace_file, _trace_depth
244
246
    _trace_file = to_file
 
247
    _trace_depth += 1
245
248
    return result
246
249
 
247
250
 
248
 
def disable_test_log((test_log_hdlr, old_trace_file)):
 
251
def disable_test_log((test_log_hdlr, old_trace_file, old_trace_depth)):
249
252
    _bzr_logger.removeHandler(test_log_hdlr)
250
253
    test_log_hdlr.close()
 
254
    global _trace_file
 
255
    global _trace_depth
251
256
    _trace_file = old_trace_file
252
 
    enable_default_logging()
 
257
    _trace_depth = old_trace_depth
 
258
    if not _trace_depth:
 
259
        enable_default_logging()
253
260
 
254
261
 
255
262
def format_exception_short(exc_info):