~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2005-05-09 03:03:55 UTC
  • Revision ID: mbp@sourcefrog.net-20050509030355-ad6ab558d1362959
- Don't give an error if the trace file can't be opened

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
    _rollover_trace_maybe(trace_fname)
107
107
 
108
108
    # buffering=1 means line buffered
109
 
    _tracefile = codecs.open(trace_fname, 'at', 'utf8', buffering=1)
110
 
    t = _tracefile
111
 
 
112
 
    if os.fstat(t.fileno())[stat.ST_SIZE] == 0:
113
 
        t.write("\nthis is a debug log for diagnosing/reporting problems in bzr\n")
114
 
        t.write("you can delete or truncate this file, or include sections in\n")
115
 
        t.write("bug reports to bazaar-ng@lists.canonical.com\n\n")
116
 
 
117
 
    import bzrlib
118
 
    _write_trace('bzr %s invoked on python %s (%s)'
119
 
                 % (bzrlib.__version__,
120
 
                    '.'.join(map(str, sys.version_info)),
121
 
                    sys.platform))
122
 
 
123
 
    _write_trace('  arguments: %r' % argv)
124
 
    _write_trace('  working dir: ' + os.getcwdu())
125
 
 
 
109
    try:
 
110
        _tracefile = codecs.open(trace_fname, 'at', 'utf8', buffering=1)
 
111
        t = _tracefile
 
112
 
 
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")
 
117
 
 
118
        import bzrlib
 
119
        _write_trace('bzr %s invoked on python %s (%s)'
 
120
                     % (bzrlib.__version__,
 
121
                        '.'.join(map(str, sys.version_info)),
 
122
                        sys.platform))
 
123
 
 
124
        _write_trace('  arguments: %r' % argv)
 
125
        _write_trace('  working dir: ' + os.getcwdu())
 
126
    except IOError, e:
 
127
        warning("failed to open trace file: %s" % (e))
126
128
 
127
129
def close_trace():
128
130
    times = os.times()