~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Lukáš Lalinský
  • Date: 2007-12-17 17:28:25 UTC
  • mfrom: (3120 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3123.
  • Revision ID: lalinsky@gmail.com-20071217172825-tr3pqm1mhvs3gwnn
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
# is quite expensive, even when the message is not printed by any handlers.
51
51
# We should perhaps change back to just simply doing it here.
52
52
 
 
53
import codecs
 
54
import logging
53
55
import os
54
56
import sys
55
57
import re
59
61
from cStringIO import StringIO
60
62
import errno
61
63
import locale
62
 
import logging
63
64
import traceback
64
65
""")
65
66
 
87
88
 
88
89
_bzr_logger = logging.getLogger('bzr')
89
90
 
 
91
 
90
92
def note(*args, **kwargs):
91
93
    # FIXME note always emits utf-8, regardless of the terminal encoding
92
94
    import bzrlib.ui
186
188
        if tf.tell() <= 2:
187
189
            tf.write("this is a debug log for diagnosing/reporting problems in bzr\n")
188
190
            tf.write("you can delete or truncate this file, or include sections in\n")
189
 
            tf.write("bug reports to bazaar@lists.canonical.com\n\n")
 
191
            tf.write("bug reports to https://bugs.launchpad.net/bzr/+filebug\n\n")
190
192
        _file_handler = logging.StreamHandler(tf)
191
193
        fmt = r'[%(process)5d] %(asctime)s.%(msecs)03d %(levelname)s: %(message)s'
192
194
        datefmt = r'%a %H:%M:%S'
212
214
    """Configure default logging to stderr and .bzr.log"""
213
215
    # FIXME: if this is run twice, things get confused
214
216
    global _stderr_handler, _file_handler, _trace_file, _bzr_log_file
215
 
    _stderr_handler = logging.StreamHandler()
 
217
    # create encoded wrapper around stderr
 
218
    stderr = codecs.getwriter(osutils.get_terminal_encoding())(sys.stderr,
 
219
        errors='replace')
 
220
    _stderr_handler = logging.StreamHandler(stderr)
216
221
    logging.getLogger('').addHandler(_stderr_handler)
217
222
    _stderr_handler.setLevel(logging.INFO)
218
223
    if not _file_handler:
377
382
        err_file.write("  %-20s %s [%s]\n" %
378
383
            (name, a_plugin.path(), a_plugin.__version__))
379
384
    err_file.write(
380
 
        "\n"
381
 
        "** Please send this report to bazaar@lists.ubuntu.com\n"
382
 
        "   with a description of what you were doing when the\n"
383
 
        "   error occurred.\n"
384
 
        )
 
385
"""\
 
386
*** Bazaar has encountered an internal error.
 
387
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
 
388
    including this traceback, and a description of what you
 
389
    were doing when the error occurred.
 
390
""")