~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:
100
100
    if hasattr(_trace_file, 'closed') and _trace_file.closed:
101
101
        return
102
102
    if len(args) > 0:
103
 
        out = fmt % args
 
103
        # It seems that if we do ascii % (unicode, ascii) we can
 
104
        # get a unicode cannot encode ascii error, so make sure that "fmt"
 
105
        # is a unicode string
 
106
        out = unicode(fmt) % args
104
107
    else:
105
108
        out = fmt
106
109
    out += '\n'
107
 
    _trace_file.write(out)
 
110
    try:
 
111
        _trace_file.write(out)
 
112
    except UnicodeError, e:
 
113
        warning('UnicodeError: %s', e)
 
114
        _trace_file.write(repr(out))
 
115
    # TODO: jam 20051227 Consider flushing the trace file to help debugging
 
116
    #_trace_file.flush()
108
117
debug = mutter
109
118
 
110
119