2020-10-30 22:00:30 +00:00
|
|
|
import logging
|
|
|
|
from helpers.os_environment import resolve_external_file_path
|
|
|
|
|
|
|
|
|
|
|
|
class LoggingManager():
|
|
|
|
|
|
|
|
logger = None
|
|
|
|
|
|
|
|
def __init__(self, name):
|
|
|
|
self.logger = logging.getLogger(name)
|
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
filename=resolve_external_file_path("/logs/" + name + ".txt"),
|
|
|
|
format='%(asctime)s | %(levelname)s | %(message)s',
|
|
|
|
level=logging.INFO,
|
|
|
|
filemode='a'
|
|
|
|
)
|
2020-10-30 23:59:58 +00:00
|
|
|
self.logger.info("** LOGGER STARTED **")
|
2020-10-30 22:00:30 +00:00
|
|
|
|
|
|
|
def __del__(self):
|
2020-10-30 23:59:58 +00:00
|
|
|
self.logger.info("** LOGGER EXITING **")
|
2020-10-30 22:00:30 +00:00
|
|
|
logging.shutdown()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def log(self):
|
|
|
|
return self.logger
|