/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/trace.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 18:10:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521181028-zn04pdfw0od9hfj3
Rename brzlib => breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
import sys
62
62
import time
63
63
 
64
 
from brzlib.lazy_import import lazy_import
 
64
from breezy.lazy_import import lazy_import
65
65
lazy_import(globals(), """
66
66
from cStringIO import StringIO
67
67
import errno
70
70
import traceback
71
71
""")
72
72
 
73
 
import brzlib
 
73
import breezy
74
74
 
75
75
lazy_import(globals(), """
76
 
from brzlib import (
 
76
from breezy import (
77
77
    debug,
78
78
    errors,
79
79
    osutils,
82
82
""")
83
83
 
84
84
 
85
 
# global verbosity for brzlib; controls the log level for stderr; 0=normal; <0
 
85
# global verbosity for breezy; controls the log level for stderr; 0=normal; <0
86
86
# is quiet; >0 is verbose.
87
87
_verbosity_level = 0
88
88
 
98
98
 
99
99
# The time the first message was written to the trace file, so that we can
100
100
# show relative times since startup.
101
 
_brz_log_start_time = brzlib._start_time
 
101
_brz_log_start_time = breezy._start_time
102
102
 
103
103
 
104
104
# held in a global for quick reference
272
272
 
273
273
    This should only be called once per process.
274
274
 
275
 
    Non-command-line programs embedding brzlib do not need to call this.  They
 
275
    Non-command-line programs embedding breezy do not need to call this.  They
276
276
    can instead either pass a file to _push_log_file, or act directly on
277
277
    logging.getLogger("brz").
278
278
 
407
407
def debug_memory(message='', short=True):
408
408
    """Write out a memory dump."""
409
409
    if sys.platform == 'win32':
410
 
        from brzlib import win32utils
 
410
        from breezy import win32utils
411
411
        win32utils.debug_memory_win32api(message=message, short=short)
412
412
    else:
413
413
        _debug_memory_proc(message=message, short=short)
456
456
            os.close(fd)
457
457
 
458
458
 
459
 
def _qualified_exception_name(eclass, unqualified_brzlib_errors=False):
 
459
def _qualified_exception_name(eclass, unqualified_breezy_errors=False):
460
460
    """Give name of error class including module for non-builtin exceptions
461
461
 
462
 
    If `unqualified_brzlib_errors` is True, errors specific to brzlib will
 
462
    If `unqualified_breezy_errors` is True, errors specific to breezy will
463
463
    also omit the module prefix.
464
464
    """
465
465
    class_name = eclass.__name__
466
466
    module_name = eclass.__module__
467
467
    if module_name in ("exceptions", "__main__") or (
468
 
            unqualified_brzlib_errors and module_name == "brzlib.errors"):
 
468
            unqualified_breezy_errors and module_name == "breezy.errors"):
469
469
        return class_name
470
470
    return "%s.%s" % (module_name, class_name)
471
471
 
539
539
 
540
540
def report_bug(exc_info, err_file):
541
541
    """Report an exception that probably indicates a bug in brz"""
542
 
    from brzlib.crash import report_bug
 
542
    from breezy.crash import report_bug
543
543
    report_bug(exc_info, err_file)
544
544
 
545
545
 
546
546
def _flush_stdout_stderr():
547
 
    # called from the brzlib library finalizer returned by brzlib.initialize()
 
547
    # called from the breezy library finalizer returned by breezy.initialize()
548
548
    try:
549
549
        sys.stdout.flush()
550
550
        sys.stderr.flush()
561
561
 
562
562
 
563
563
def _flush_trace():
564
 
    # called from the brzlib library finalizer returned by brzlib.initialize()
 
564
    # called from the breezy library finalizer returned by breezy.initialize()
565
565
    global _trace_file
566
566
    if _trace_file:
567
567
        _trace_file.flush()
611
611
 
612
612
 
613
613
class Config(object):
614
 
    """Configuration of message tracing in brzlib.
 
614
    """Configuration of message tracing in breezy.
615
615
 
616
616
    This implements the context manager protocol and should manage any global
617
617
    variables still used. The default config used is DefaultConfig, but
618
 
    embedded uses of brzlib may wish to use a custom manager.
 
618
    embedded uses of breezy may wish to use a custom manager.
619
619
    """
620
620
 
621
621
    def __enter__(self):
626
626
 
627
627
 
628
628
class DefaultConfig(Config):
629
 
    """A default configuration for tracing of messages in brzlib.
 
629
    """A default configuration for tracing of messages in breezy.
630
630
 
631
631
    This implements the context manager protocol.
632
632
    """