From 64d01befe0bfbffad7224fa187600d8ed2ba2d53 Mon Sep 17 00:00:00 2001 From: Sethu Date: Fri, 23 Aug 2024 15:40:02 +0530 Subject: [PATCH] added logger --- logger.py | 16 ++++++++++++++++ logging.connf | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 logger.py create mode 100644 logging.connf diff --git a/logger.py b/logger.py new file mode 100644 index 0000000..b323b73 --- /dev/null +++ b/logger.py @@ -0,0 +1,16 @@ +from os import path +import logging +import logging.config + +#log_file_path = path.join(path.dirname(path.abspath(__file__)), 'log.config') +#logging.config.fileConfig(log_file_path) + +# create logger +logger = logging.getLogger('simpleExample') + +# 'application' code +logger.debug('debug message') +logger.info('info message') +logger.warning('warn message') +logger.error('error message') +logger.critical('critical message') diff --git a/logging.connf b/logging.connf new file mode 100644 index 0000000..63c8dcf --- /dev/null +++ b/logging.connf @@ -0,0 +1,27 @@ +[loggers] +keys=root,simpleExample + +[handlers] +keys=consoleHandler + +[formatters] +keys=simpleFormatter + +[logger_root] +level=DEBUG +handlers=consoleHandler + +[logger_simpleExample] +level=DEBUG +handlers=consoleHandler +qualname=simpleExample +propagate=0 + +[handler_consoleHandler] +class=StreamHandler +level=DEBUG +formatter=simpleFormatter +args=(sys.stdout,) + +[formatter_simpleFormatter] +format=%(asctime)s - %(name)s - %(levelname)s - %(message)s