~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-24 00:08:33 UTC
  • mfrom: (1954 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1979.
  • Revision ID: john@arbash-meinel.com-20060824000833-f32d5cbef4fa4f78
[merge] bzr.dev 1954

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
        return
96
96
    if hasattr(_trace_file, 'closed') and _trace_file.closed:
97
97
        return
 
98
 
 
99
    if isinstance(fmt, unicode):
 
100
        fmt = fmt.encode('utf8')
 
101
 
98
102
    if len(args) > 0:
99
103
        # It seems that if we do ascii % (unicode, ascii) we can
100
104
        # get a unicode cannot encode ascii error, so make sure that "fmt"
101
105
        # is a unicode string
102
 
        out = unicode(fmt) % args
 
106
        real_args = []
 
107
        for arg in args:
 
108
            if isinstance(arg, unicode):
 
109
                arg = arg.encode('utf8')
 
110
            real_args.append(arg)
 
111
        out = fmt % tuple(real_args)
103
112
    else:
104
113
        out = fmt
105
114
    out += '\n'
106
 
    try:
107
 
        _trace_file.write(out)
108
 
    except UnicodeError, e:
109
 
        warning('UnicodeError: %s', e)
110
 
        _trace_file.write(repr(out))
 
115
    _trace_file.write(out)
111
116
    # TODO: jam 20051227 Consider flushing the trace file to help debugging
112
117
    #_trace_file.flush()
113
118
debug = mutter
137
142
    _rollover_trace_maybe(trace_fname)
138
143
    try:
139
144
        LINE_BUFFERED = 1
140
 
        tf = codecs.open(trace_fname, 'at', 'utf8', buffering=LINE_BUFFERED)
 
145
        #tf = codecs.open(trace_fname, 'at', 'utf8', buffering=LINE_BUFFERED)
 
146
        tf = open(trace_fname, 'at', LINE_BUFFERED)
141
147
        _bzr_log_file = tf
142
148
        if tf.tell() == 0:
143
149
            tf.write("\nthis is a debug log for diagnosing/reporting problems in bzr\n")