add log to file in /var/log

This commit is contained in:
sinseman44
2020-11-15 09:21:08 +00:00
parent 537827bf37
commit 887807f289
2 changed files with 17 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
import os
import sys
import time
import logging
import RPi.GPIO as GPIO
from RPLCD.gpio import CharLCD
from piplot.config import *
@@ -76,14 +77,17 @@ def init():
GPIO.add_event_detect(PG_OK, GPIO.RISING, callback=pg_ok_cb, bouncetime=50)
except:
e = sys.exc_info()[1]
print("Error : {}".format(e))
logging.error("Error : {}".format(e))
sys.exit(1)
menu.init_menu()
def main():
logging.basicConfig(filename='/var/log/PiPlot2D.log', level=logging.INFO)
logging.info("*** Launch PiPlot2D Menu & Control ***")
init()
while True:
time.sleep(1)
logging.info("*** Exit PiPlot2D Menu & Control ***")
lcd.close()
###################################################################