From de53538487244baa3e2f334edb3e55814f847ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 25 Feb 2017 19:04:09 +0000 Subject: Add a --vlog option to enable verbose logging. This helps adding debug information to drivers, particularly those sending encoded messages. --- glucometer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glucometer.py b/glucometer.py index 3e6105b..be8fb02 100755 --- a/glucometer.py +++ b/glucometer.py @@ -9,6 +9,7 @@ __license__ = 'MIT' import argparse import importlib +import logging import sys from dateutil import parser as date_parser @@ -27,6 +28,11 @@ def main(): '--device', action='store', required=True, help='Select the path to the glucometer device.') + parser.add_argument( + '--vlog', action='store', required=False, type=int, + help=('Python logging level. See the levels at ' + 'https://docs.python.org/3/library/logging.html#logging-levels')) + subparsers.add_parser( 'info', help='Display information about the meter.') subparsers.add_parser( @@ -50,6 +56,8 @@ def main(): args = parser.parse_args() + logging.basicConfig(level=args.vlog) + driver = importlib.import_module('glucometerutils.drivers.' + args.driver) device = driver.Device(args.device) -- cgit v1.2.3