From 666405bfa22af554d14eea9179109932258193e4 Mon Sep 17 00:00:00 2001 From: Emanuele Date: Fri, 27 Sep 2019 15:57:07 +0200 Subject: [PATCH] Aggiunto logging --- MkpWIFI/log/dimelog.log | 2 ++ MkpWIFI/mainDime.py | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 MkpWIFI/log/dimelog.log diff --git a/MkpWIFI/log/dimelog.log b/MkpWIFI/log/dimelog.log new file mode 100644 index 0000000..85d1694 --- /dev/null +++ b/MkpWIFI/log/dimelog.log @@ -0,0 +1,2 @@ +09-27 15:54:43|WARNING| |36 : MarcaturaDime Started! +09-27 15:55:11|WARNING| |36 : MarcaturaDime Started! diff --git a/MkpWIFI/mainDime.py b/MkpWIFI/mainDime.py index 89577fe..a15825d 100644 --- a/MkpWIFI/mainDime.py +++ b/MkpWIFI/mainDime.py @@ -5,15 +5,34 @@ Created on 27 set 2019 ''' import time import sys -import printer +import printer as p import commands +import logging def main(): - printer = printer.MarkoPrinter('./conf.json') + printer = p.MarkoPrinter('./conf.json') printer.connetti() pass if __name__ == '__main__': + # Setup Logger + LOGGER = logging.getLogger(__name__) + LOGGER.setLevel(logging.DEBUG) + LOGGER.propagate = False + FORMATTER = logging.Formatter(("%(asctime)s|%(levelname)-7s|%(funcName)-10s|%(lineno)-3d: %(message)-50s"), + ("%m-%d %H:%M:%S")) + # File Logging + fh = logging.FileHandler(("./log/dimelog.log")) + fh.setLevel(logging.WARNING) + fh.setFormatter(FORMATTER) + LOGGER.addHandler(fh) + # Console Logging + cl= logging.StreamHandler(sys.stdout) + cl.setLevel(logging.INFO) + cl.setFormatter(FORMATTER) + LOGGER.addHandler(cl) + + LOGGER.warning("MarcaturaDime Started!") sys.exit(main()) pass \ No newline at end of file