~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-10 01:15:47 UTC
  • mfrom: (3170.1.2 debug-timestamps)
  • Revision ID: pqm@pqm.ubuntu.com-20080110011547-97smthgbb8hfshs7
(andrew) Add -Dtimes debug flag.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
import os
56
56
import sys
57
57
import re
 
58
import time
58
59
 
59
60
from bzrlib.lazy_import import lazy_import
60
61
lazy_import(globals(), """
82
83
_trace_depth = 0
83
84
_bzr_log_file = None
84
85
_bzr_log_filename = None
 
86
_bzr_log_opened = None
85
87
 
86
88
 
87
89
# configure convenient aliases for output routines
127
129
    else:
128
130
        out = fmt
129
131
    out += '\n'
 
132
    if 'times' in debug.debug_flags:
 
133
        global _bzr_log_opened
 
134
        if _bzr_log_opened is None:
 
135
            # This is the first mutter since the process started.  Start the
 
136
            # clock from now.
 
137
            _bzr_log_opened = time.time()
 
138
        timestamp = '%0.3f' % (time.time() - _bzr_log_opened,)
 
139
        out = '%s %s' % (timestamp, out)
130
140
    _trace_file.write(out)
131
141
    # TODO: jam 20051227 Consider flushing the trace file to help debugging
132
142
    #_trace_file.flush()