diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-09-11 16:43:22 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-09-11 16:54:59 +0900 |
commit | b1adb9b986f6f1b1c27cb103efbe7fa6e62ac5ef (patch) | |
tree | 1fbc936525bbf5073d998fd7eaaddc8139d928b0 /example.py | |
parent | 377d5f2dc91ac045f6148053112f59b4ba768b92 (diff) | |
download | pygerrit-b1adb9b986f6f1b1c27cb103efbe7fa6e62ac5ef.tar.gz |
Improved logging in the example script
- Add --verbose option to enable DEBUG logging.
- Add timestamp and log level to the output format.
Change-Id: I11ca42095d7ee24782d39141fae20b8b26695fff
Diffstat (limited to 'example.py')
-rwxr-xr-x | example.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -49,12 +49,17 @@ def _main(): default=None, type='int', help='timeout (seconds) for blocking event get ' '(default: None)') + parser.add_option('-v', '--verbose', dest='verbose', + action='store_true', + help='enable verbose (debug) logging') (options, _args) = parser.parse_args() if options.timeout and not options.blocking: parser.error('Can only use --timeout with --blocking') - logging.basicConfig(format='%(message)s', level=logging.INFO) + level = logging.DEBUG if options.verbose else logging.INFO + logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', + level=level) try: gerrit = GerritClient(host=options.hostname) @@ -83,6 +88,7 @@ def _main(): except KeyboardInterrupt: logging.info("Terminated by user") finally: + logging.debug("Stopping event stream...") gerrit.stop_event_stream() if errors.isSet(): |