Skip to content

Commit

Permalink
glance-replicator: enable logging exceptions into log file
Browse files Browse the repository at this point in the history
bug 1213779

Currently, glance-replicator provides option to enable logging
information into a specified file. But exceptions are not logged
into the log file when they are thrown.

Reproduce steps:

When setting a wrong source or target address, exceptions would be
thrown, but not logged into log file.

Change-Id: Ic2c59e04aa6099f3ede0c6b8579c31a3dfff895c
  • Loading branch information
yufang521247 committed Aug 19, 2013
1 parent 9cd75d0 commit aca3ca0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions glance/cmd/replicator.py
Expand Up @@ -714,6 +714,12 @@ def lookup_command(parser, command_name):
return command


def logging_excepthook(type, value, tb):
extra = {}
extra['exc_info'] = (type, value, tb)
logging.critical(str(value), **extra)


def main():
usage = """
%%prog <command> [options] [args]
Expand Down Expand Up @@ -771,6 +777,8 @@ def main():
else:
handler = logging.StreamHandler(sys.stdout)

sys.excepthook = logging_excepthook

if options.token:
options.slavetoken = options.token
options.mastertoken = options.token
Expand Down

0 comments on commit aca3ca0

Please sign in to comment.