122
123
# FIXME: clearing the ui and then going through the abstract logging
123
124
# framework is whack; we should probably have a logging Handler that
124
125
# deals with terminal output if needed.
126
bzrlib.ui.ui_factory.clear_term()
126
ui.ui_factory.clear_term()
127
127
_bzr_logger.info(*args, **kwargs)
130
130
def warning(*args, **kwargs):
132
bzrlib.ui.ui_factory.clear_term()
131
ui.ui_factory.clear_term()
133
132
_bzr_logger.warning(*args, **kwargs)
471
def _dump_memory_usage(err_file):
474
fd, name = tempfile.mkstemp(prefix="bzr_memdump", suffix=".json")
475
dump_file = os.fdopen(fd, 'w')
476
from meliae import scanner
477
scanner.dump_gc_objects(dump_file)
478
err_file.write("Memory dumped to %s\n" % name)
480
err_file.write("Dumping memory requires meliae module.\n")
481
log_exception_quietly()
483
err_file.write("Exception while dumping memory.\n")
484
log_exception_quietly()
486
if dump_file is not None:
492
def _qualified_exception_name(eclass, unqualified_bzrlib_errors=False):
493
"""Give name of error class including module for non-builtin exceptions
495
If `unqualified_bzrlib_errors` is True, errors specific to bzrlib will
496
also omit the module prefix.
498
class_name = eclass.__name__
499
module_name = eclass.__module__
500
if module_name in ("exceptions", "__main__") or (
501
unqualified_bzrlib_errors and module_name == "bzrlib.errors"):
503
return "%s.%s" % (module_name, class_name)
473
506
def report_exception(exc_info, err_file):
474
507
"""Report an exception to err_file (typically stderr) and to .bzr.log.
492
525
return errors.EXIT_ERROR
493
526
elif isinstance(exc_object, MemoryError):
494
527
err_file.write("bzr: out of memory\n")
528
if 'mem_dump' in debug.debug_flags:
529
_dump_memory_usage(err_file)
531
err_file.write("Use -Dmem_dump to dump memory to a file.\n")
495
532
return errors.EXIT_ERROR
496
533
elif isinstance(exc_object, ImportError) \
497
534
and str(exc_object).startswith("No module named "):