~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

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