Fixes for common logger object

This commit is contained in:
Patrick McDonagh
2018-07-03 15:19:08 -05:00
parent 21cc94c919
commit 7c690affb5
5 changed files with 44 additions and 37 deletions

View File

@@ -0,0 +1,18 @@
"""Logging setup for multisensor"""
import logging
from logging.handlers import RotatingFileHandler
import sys
log_formatter = logging.Formatter('%(asctime)s %(levelname)s %(funcName)s(%(lineno)d) %(message)s')
log_file = './multisensor.log'
my_handler = RotatingFileHandler(log_file, mode='a', maxBytes=500*1024,
backupCount=2, encoding=None, delay=0)
my_handler.setFormatter(log_formatter)
my_handler.setLevel(logging.INFO)
filelogger = logging.getLogger('multisensor')
filelogger.setLevel(logging.INFO)
filelogger.addHandler(my_handler)
console_out = logging.StreamHandler(sys.stdout)
console_out.setFormatter(log_formatter)
filelogger.addHandler(console_out)