/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: 2020-02-07 02:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200207021430-m49iq3x4x8xlib6x
Drop python2 support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
# that.
58
58
 
59
59
import errno
 
60
from io import StringIO
60
61
import logging
61
62
import os
62
63
import sys
82
83
    errors,
83
84
    )
84
85
 
85
 
from .sixish import (
86
 
    PY3,
87
 
    StringIO,
88
 
    text_type,
89
 
    )
90
 
 
91
86
 
92
87
# global verbosity for breezy; controls the log level for stderr; 0=normal; <0
93
88
# is quiet; >0 is verbose.
162
157
        fmt = fmt.decode('ascii', 'replace')
163
158
 
164
159
    if args:
165
 
        if not PY3:
166
 
            args = tuple(
167
 
                _Bytes(arg) if isinstance(arg, bytes) else arg for arg in args)
168
160
        out = fmt % args
169
161
    else:
170
162
        out = fmt
306
298
        r'%Y-%m-%d %H:%M:%S')
307
299
    # after hooking output into brz_log, we also need to attach a stderr
308
300
    # handler, writing only at level info and with encoding
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)
 
301
    stderr_handler = logging.StreamHandler(stream=sys.stderr)
315
302
    logging.getLogger('brz').addHandler(stderr_handler)
316
303
    return memento
317
304
 
615
602
 
616
603
    def emit(self, record):
617
604
        try:
618
 
            if not isinstance(record.msg, text_type):
 
605
            if not isinstance(record.msg, str):
619
606
                msg = record.msg.decode("utf-8")
620
 
                if PY3:
621
 
                    record.msg = msg
 
607
                record.msg = msg
622
608
            line = self.format(record)
623
 
            if not isinstance(line, text_type):
 
609
            if not isinstance(line, str):
624
610
                line = line.decode("utf-8")
625
611
            self.stream.write(line.encode(self.encoding, self.errors) + b"\n")
626
612
        except Exception: