~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

 * bzr add now lists how many files were ignored per glob.  add --verbose
   lists the specific files.  (Aaron Bentley)

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
223
 
    
224
 
    returns an opaque reference that should be passed to disable_test_log
225
 
    after the test complete.
226
 
    """
 
222
    """Redirect logging to a temporary file for a test"""
227
223
    disable_default_logging()
228
 
    global _trace_file
 
224
    global _test_log_hdlr, _trace_file
229
225
    hdlr = logging.StreamHandler(to_file)
230
226
    hdlr.setLevel(logging.DEBUG)
231
227
    hdlr.setFormatter(logging.Formatter('%(levelname)8s  %(message)s'))
232
228
    _bzr_logger.addHandler(hdlr)
233
229
    _bzr_logger.setLevel(logging.DEBUG)
234
 
    result = hdlr, _trace_file
 
230
    _test_log_hdlr = hdlr
235
231
    _trace_file = to_file
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
 
232
 
 
233
 
 
234
def disable_test_log():
 
235
    _bzr_logger.removeHandler(_test_log_hdlr)
 
236
    _trace_file = None
242
237
    enable_default_logging()
243
238
 
244
239