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.
168
cmd_repr = ' '.join(repr(arg) for arg in sys.argv)
169
cmd_info = '\n command: %s\n pwd: %s' \
170
% (cmd_repr, os.getcwd())
164
command = ' '.join(repr(arg) for arg in sys.argv)
165
prefix = "command: %s\npwd: %s\n" % (command, os.getcwd())
172
167
ei = sys.exc_info()
174
169
if msg and (msg[-1] == '\n'):
176
171
## msg = "(%s) %s" % (str(type(ei[1])), msg)
177
_bzr_logger.exception(msg + cmd_info)
181
def log_exception_quietly():
182
"""Log the last exception to the trace file only.
184
Used for exceptions that occur internally and that may be
185
interesting to developers but not to users. For example,
186
errors loading plugins.
188
debug(traceback.format_exc())
172
_bzr_logger.exception(prefix + msg)
191
176
def enable_default_logging():