/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2005-05-09 03:02:23 UTC
  • Revision ID: mbp@sourcefrog.net-20050509030223-b2d759eebe6af62c
- Update todo list

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14
14
 
15
15
 
16
 
 
17
 
# TODO: Could probably replace this with something based on Python logging
18
 
# module.
19
 
 
20
 
 
21
 
 
22
 
 
23
16
__copyright__ = "Copyright (C) 2005 Canonical Ltd."
24
17
__author__ = "Martin Pool <mbp@canonical.com>"
25
18
 
52
45
 
53
46
 
54
47
def _write_trace(msg):
55
 
    if 0:
56
 
        if _tracefile:
57
 
            _tracefile.write(_logprefix + msg + '\n')
 
48
    if _tracefile:
 
49
        _tracefile.write(_logprefix + msg + '\n')
58
50
 
59
51
 
60
52
def warning(msg):
114
106
    _rollover_trace_maybe(trace_fname)
115
107
 
116
108
    # buffering=1 means line buffered
117
 
    try:
118
 
        _tracefile = codecs.open(trace_fname, 'at', 'utf8', buffering=1)
119
 
        t = _tracefile
120
 
 
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")
125
 
 
126
 
        import bzrlib
127
 
        _write_trace('bzr %s invoked on python %s (%s)'
128
 
                     % (bzrlib.__version__,
129
 
                        '.'.join(map(str, sys.version_info)),
130
 
                        sys.platform))
131
 
 
132
 
        _write_trace('  arguments: %r' % argv)
133
 
        _write_trace('  working dir: ' + os.getcwdu())
134
 
    except IOError, e:
135
 
        warning("failed to open trace file: %s" % (e))
 
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
 
136
126
 
137
127
def close_trace():
138
128
    times = os.times()