~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2008-06-11 02:36:40 UTC
  • mfrom: (3490 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3492.
  • Revision ID: mbp@sourcefrog.net-20080611023640-db0lqd75yueksdw7
Merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
295
295
    This flushes, but does not close the trace file.
296
296
    
297
297
    Takes the memento returned from _push_log_file."""
298
 
    assert magic == 'log_memento'
299
298
    global _trace_file
300
299
    _trace_file = old_trace_file
301
300
    bzr_logger = logging.getLogger('bzr')
415
414
        return errors.EXIT_INTERNAL_ERROR
416
415
 
417
416
 
 
417
def print_exception(exc_info, err_file):
 
418
    exc_type, exc_object, exc_tb = exc_info
 
419
    err_file.write("bzr: ERROR: %s.%s: %s\n" % (
 
420
        exc_type.__module__, exc_type.__name__, exc_object))
 
421
    err_file.write('\n')
 
422
    traceback.print_exception(exc_type, exc_object, exc_tb, file=err_file)
 
423
 
 
424
 
418
425
# TODO: Should these be specially encoding the output?
419
426
def report_user_error(exc_info, err_file):
420
427
    """Report to err_file an error that's not an internal error.
422
429
    These don't get a traceback unless -Derror was given.
423
430
    """
424
431
    if 'error' in debug.debug_flags:
425
 
        report_bug(exc_info, err_file)
 
432
        print_exception(exc_info, err_file)
426
433
        return
427
434
    err_file.write("bzr: ERROR: %s\n" % (exc_info[1],))
428
435
 
429
436
 
430
437
def report_bug(exc_info, err_file):
431
438
    """Report an exception that probably indicates a bug in bzr"""
432
 
    exc_type, exc_object, exc_tb = exc_info
433
 
    err_file.write("bzr: ERROR: %s.%s: %s\n" % (
434
 
        exc_type.__module__, exc_type.__name__, exc_object))
435
 
    err_file.write('\n')
436
 
    traceback.print_exception(exc_type, exc_object, exc_tb, file=err_file)
 
439
    print_exception(exc_info, err_file)
437
440
    err_file.write('\n')
438
441
    err_file.write('bzr %s on python %s (%s)\n' % \
439
442
                       (bzrlib.__version__,