/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

Support user.signingkey configuration variable in .git/config.

Merged from https://code.launchpad.net/~jelmer/brz/local-git-key/+merge/381000

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
form.
46
46
"""
47
47
 
 
48
from __future__ import absolute_import
 
49
 
48
50
# FIXME: Unfortunately it turns out that python's logging module
49
51
# is quite expensive, even when the message is not printed by any handlers.
50
52
# We should perhaps change back to just simply doing it here.
55
57
# that.
56
58
 
57
59
import errno
58
 
from io import StringIO
59
60
import logging
60
61
import os
61
62
import sys
81
82
    errors,
82
83
    )
83
84
 
 
85
from .sixish import (
 
86
    PY3,
 
87
    StringIO,
 
88
    text_type,
 
89
    )
 
90
 
84
91
 
85
92
# global verbosity for breezy; controls the log level for stderr; 0=normal; <0
86
93
# is quiet; >0 is verbose.
155
162
        fmt = fmt.decode('ascii', 'replace')
156
163
 
157
164
    if args:
 
165
        if not PY3:
 
166
            args = tuple(
 
167
                _Bytes(arg) if isinstance(arg, bytes) else arg for arg in args)
158
168
        out = fmt % args
159
169
    else:
160
170
        out = fmt
296
306
        r'%Y-%m-%d %H:%M:%S')
297
307
    # after hooking output into brz_log, we also need to attach a stderr
298
308
    # handler, writing only at level info and with encoding
299
 
    stderr_handler = logging.StreamHandler(stream=sys.stderr)
 
309
    if sys.version_info[0] == 2:
 
310
        stderr_handler = EncodedStreamHandler(
 
311
            sys.stderr, osutils.get_terminal_encoding(), 'replace',
 
312
            level=logging.INFO)
 
313
    else:
 
314
        stderr_handler = logging.StreamHandler(stream=sys.stderr)
300
315
    logging.getLogger('brz').addHandler(stderr_handler)
301
316
    return memento
302
317
 
600
615
 
601
616
    def emit(self, record):
602
617
        try:
603
 
            if not isinstance(record.msg, str):
 
618
            if not isinstance(record.msg, text_type):
604
619
                msg = record.msg.decode("utf-8")
605
 
                record.msg = msg
 
620
                if PY3:
 
621
                    record.msg = msg
606
622
            line = self.format(record)
607
 
            if not isinstance(line, str):
 
623
            if not isinstance(line, text_type):
608
624
                line = line.decode("utf-8")
609
625
            self.stream.write(line.encode(self.encoding, self.errors) + b"\n")
610
626
        except Exception: