13
13
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
# TODO: Could probably replace this with something based on Python logging
23
16
__copyright__ = "Copyright (C) 2005 Canonical Ltd."
24
17
__author__ = "Martin Pool <mbp@canonical.com>"
104
def open_tracefile(argv=[], tracefilename='~/.bzr.log'):
97
def open_tracefile(argv):
105
98
# Messages are always written to here, so that we have some
106
99
# information if something goes wrong. In a future version this
107
100
# file will be removed on successful completion.
111
104
_starttime = os.times()[4]
113
trace_fname = os.path.join(os.path.expanduser(tracefilename))
106
trace_fname = os.path.join(os.path.expanduser('~/.bzr.log'))
114
107
_rollover_trace_maybe(trace_fname)
116
109
# buffering=1 means line buffered
118
_tracefile = codecs.open(trace_fname, 'at', 'utf8', buffering=1)
121
if os.fstat(t.fileno())[stat.ST_SIZE] == 0:
122
t.write("\nthis is a debug log for diagnosing/reporting problems in bzr\n")
123
t.write("you can delete or truncate this file, or include sections in\n")
124
t.write("bug reports to bazaar-ng@lists.canonical.com\n\n")
127
_write_trace('bzr %s invoked on python %s (%s)'
128
% (bzrlib.__version__,
129
'.'.join(map(str, sys.version_info)),
132
_write_trace(' arguments: %r' % argv)
133
_write_trace(' working dir: ' + os.getcwdu())
135
warning("failed to open trace file: %s" % (e))
110
_tracefile = codecs.open(trace_fname, 'at', 'utf8', buffering=1)
113
if os.fstat(t.fileno())[stat.ST_SIZE] == 0:
114
t.write("\nthis is a debug log for diagnosing/reporting problems in bzr\n")
115
t.write("you can delete or truncate this file, or include sections in\n")
116
t.write("bug reports to bazaar-ng@lists.canonical.com\n\n")
118
# TODO: If we failed to create the file, perhaps give a warning
119
# but don't abort; send things to /dev/null instead?
121
_write_trace('bzr %s invoked on python %s (%s)'
122
% (bzrlib.__version__,
123
'.'.join(map(str, sys.version_info)),
126
_write_trace(' arguments: %r' % argv)
127
_write_trace(' working dir: ' + os.getcwdu())
137
130
def close_trace():
138
131
times = os.times()