137
def open_tracefile(tracefilename='~/.bzr.log'):
140
def open_tracefile(tracefilename=None):
138
141
# Messages are always written to here, so that we have some
139
142
# information if something goes wrong. In a future version this
140
143
# file will be removed on successful completion.
141
144
global _file_handler, _bzr_log_file
144
trace_fname = os.path.join(os.path.expanduser(tracefilename))
147
if tracefilename is None:
148
if sys.platform == 'win32':
149
from bzrlib import win32utils
150
home = win32utils.get_home_location()
152
home = os.path.expanduser('~')
153
tracefilename = os.path.join(home, '.bzr.log')
155
trace_fname = os.path.expanduser(tracefilename)
145
156
_rollover_trace_maybe(trace_fname)
147
158
LINE_BUFFERED = 1
148
159
#tf = codecs.open(trace_fname, 'at', 'utf8', buffering=LINE_BUFFERED)
149
160
tf = open(trace_fname, 'at', LINE_BUFFERED)
150
161
_bzr_log_file = tf
152
tf.write("\nthis is a debug log for diagnosing/reporting problems in bzr\n")
162
# tf.tell() on windows always return 0 until some writing done
165
tf.write("this is a debug log for diagnosing/reporting problems in bzr\n")
153
166
tf.write("you can delete or truncate this file, or include sections in\n")
154
tf.write("bug reports to bazaar-ng@lists.canonical.com\n\n")
167
tf.write("bug reports to bazaar@lists.canonical.com\n\n")
155
168
_file_handler = logging.StreamHandler(tf)
156
169
fmt = r'[%(process)5d] %(asctime)s.%(msecs)03d %(levelname)s: %(message)s'
157
170
datefmt = r'%a %H:%M:%S'
282
297
# TODO: Should these be specially encoding the output?
283
298
def report_user_error(exc_info, err_file):
299
"""Report to err_file an error that's not an internal error.
301
These don't get a traceback unless -Derror was given.
303
if 'error' in debug.debug_flags:
304
report_bug(exc_info, err_file)
284
306
print >>err_file, "bzr: ERROR:", str(exc_info[1])
300
322
print >>err_file, 'arguments: %r' % sys.argv
302
print >>err_file, "** please send this report to bazaar-ng@lists.ubuntu.com"
324
print >>err_file, "** please send this report to bazaar@lists.ubuntu.com"