X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/b17f34b42aa5e6ca959d8f3d748012c87d4d8999..df20089d0d749ef7cccc25f4567203a010e31e8d:/examples/weather.py?ds=inline diff --git a/examples/weather.py b/examples/weather.py index 17aba20..5036021 100755 --- a/examples/weather.py +++ b/examples/weather.py @@ -8,7 +8,14 @@ try: except ImportError: from smbus import SMBus -print("""weather.py - Print readings from the BME280 weather sensor. +import logging + +logging.basicConfig( + format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s', + level=logging.INFO, + datefmt='%Y-%m-%d %H:%M:%S') + +logging.info("""weather.py - Print readings from the BME280 weather sensor. Press Ctrl+C to exit! @@ -21,7 +28,7 @@ while True: temperature = bme280.get_temperature() pressure = bme280.get_pressure() humidity = bme280.get_humidity() - print("""Temperature: {:05.2f} *C + logging.info("""Temperature: {:05.2f} *C Pressure: {:05.2f} hPa Relative humidity: {:05.2f} % """.format(temperature, pressure, humidity))