fixed a minor bug in how the logger is created

pull/191/head
Chris Veilleux 2019-06-27 17:23:37 -05:00
parent 57bbf00baa
commit 61a7b6b7a0
2 changed files with 5 additions and 7 deletions

View File

@ -6,7 +6,6 @@ jobs, such as argument parsing, logging setup and database connectivity.
"""
from argparse import ArgumentParser
from datetime import date, datetime
from logging import getLogger
from os import environ, path
import sys
@ -21,8 +20,7 @@ class SeleneScript(object):
def __init__(self, job_file_path):
self._job_file_path = job_file_path
configure_logger(self.job_name)
self.log = getLogger(self.job_name)
self.log = configure_logger(self.job_name)
self._arg_parser = ArgumentParser()
self.args = None
self.start_ts = datetime.now()

View File

@ -34,12 +34,12 @@ from logging import (
class LoggingConfig(object):
"""Configure a logger with a daily log file and a console log"""
def __init__(self, log_file_name):
self.logger = getLogger()
def __init__(self, logger_name):
self.logger = getLogger(logger_name)
self.logger.level = DEBUG
self.file_log_level = DEBUG
self.console_log_level = INFO
self.log_file_path = path.join('/var/log/mycroft', log_file_name)
self.log_file_path = path.join('/var/log/mycroft', logger_name + '.log')
self.log_msg_formatter = Formatter(
'{asctime} | {levelname:8} | {process:5} | {name} | {message}',
style='{'
@ -75,7 +75,7 @@ class LoggingConfig(object):
def configure_logger(logger_name: str):
"""helper function that returns a logger using the base config"""
logging_config = LoggingConfig(logger_name + '.log')
logging_config = LoggingConfig(logger_name)
logging_config.configure()
return logging_config.logger