~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2005-09-16 09:19:54 UTC
  • Revision ID: mbp@sourcefrog.net-20050916091954-aee6d7be00db6354
- more docs in commit code

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        if record.levelno >= logging.WARNING:
59
59
            s += record.levelname + ': '
60
60
            
61
 
        s += record.getMessage() 
 
61
        s += record.getMessage()
 
62
 
 
63
        import textwrap
 
64
        s = textwrap.fill(s)
62
65
            
63
66
        if record.exc_info:
64
67
            # give just a summary of the exception, not the whole thing
181
184
    global _stderr_handler, _file_handler
182
185
 
183
186
    _stderr_handler = logging.StreamHandler()
184
 
    _stderr_handler.setFormatter(QuietFormatter())
185
187
 
186
188
    if not _file_handler:
187
 
        open_tracefile()
 
189
        open_tracefile()                # also adds it
188
190
 
189
 
    if os.environ.get('BZR_DEBUG'):
 
191
    debug_flag = False
 
192
    try:
 
193
        debug_flag = bool(os.environ['BZR_DEBUG'])
 
194
    except:
 
195
        pass
 
196
        
 
197
    if debug_flag:
190
198
        level = logging.DEBUG
 
199
        fmt = '%(levelname)8s: %(message)s'
 
200
        _stderr_handler.setFormatter(logging.Formatter(fmt))
191
201
    else:
192
202
        level = logging.INFO
 
203
        # show only summary of exceptions
 
204
        _stderr_handler.setFormatter(QuietFormatter())
193
205
 
194
 
    _stderr_handler.setLevel(logging.INFO)
 
206
    _stderr_handler.setLevel(level)
195
207
    _file_handler.setLevel(level)
196
208
 
197
209
    logging.getLogger('').addHandler(_stderr_handler)