33
33
# TODO: When running the test suites, we should add an additional
34
34
# logger that sends messages into the test log file.
36
# FIXME: Unfortunately it turns out that python's logging module
37
# is quite expensive, even when the message is not printed by any handlers.
38
# We should perhaps change back to just simply doing it here.
158
154
debug(' arguments: %r', argv)
159
debug(' working dir: %r', os.getcwdu())
155
debug(' working dir: %s', os.getcwdu())
162
158
def log_exception(msg=None):
163
"""Log the last exception to stderr and the trace file.
159
"""Log the last exception into the trace file.
165
161
The exception string representation is used as the error
166
162
summary, unless msg is given.
164
cmd_repr = ' '.join(repr(arg) for arg in sys.argv)
165
cmd_info = '\n command: %s\n pwd: %s' \
166
% (cmd_repr, os.getcwd())
171
170
if msg and (msg[-1] == '\n'):
173
msg += '\n command: %s' % ' '.join(repr(arg) for arg in sys.argv)
174
msg += '\n pwd: %r' % os.getcwdu()
175
msg += '\n error: %s' % ei[0] # exception type
176
_bzr_logger.exception(msg)
179
def log_exception_quietly():
180
"""Log the last exception to the trace file only.
182
Used for exceptions that occur internally and that may be
183
interesting to developers but not to users. For example,
184
errors loading plugins.
186
debug(traceback.format_exc())
172
## msg = "(%s) %s" % (str(type(ei[1])), msg)
173
_bzr_logger.exception(msg + cmd_info)
189
177
def enable_default_logging():