From: gregor herrmann Date: Sun, 9 Feb 2020 00:42:14 +0000 (+0100) Subject: configure logging module X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/commitdiff_plain/3f3b346ada7cf690fb3f852aff925d740b288128 configure logging module otherwise logging.info() doesn't print anything, as the default level is warn. hide the senor output behind a check for --verbose --- diff --git a/seewasser.py b/seewasser.py index 5bf2ce2..922a990 100755 --- a/seewasser.py +++ b/seewasser.py @@ -12,6 +12,8 @@ from sqlalchemy import create_engine import warnings import MySQLdb.cursors +logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) + #May 27 21:32 /sys/bus/w1/devices/28-0416a1bab9ff #May 27 21:33 /sys/bus/w1/devices/28-0416a1ac66ff #May 27 21:35 /sys/bus/w1/devices/28-0516a207a4ff @@ -109,7 +111,8 @@ def main(configfile, fromcsvfile): timestamp, value_raw, value = readsensor(sensor_id) writesensordatacsv(config, sensor_id, sensor_name, timestamp, value_type, value_raw, value) writesensordatadb(config, sensor_id, sensor_name, timestamp, value_type, value_raw, value) - logging.info('Sensor {}: {:.1f}°C'.format(sensor_id, value)) + if args.verbose: + logging.info('Sensor {}: {:.1f}°C'.format(sensor_id, value)) if __name__ == '__main__':