Skip to content

Commit

Permalink
Merge pull request #15 from MinionAttack/development
Browse files Browse the repository at this point in the history
Improve logging class and update dependencies
  • Loading branch information
MinionAttack committed Sep 26, 2021
2 parents 7a53db9 + ff404de commit 090dd1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cffi==1.14.6
chardet==4.0.0
cryptography==3.4.8
cssselect==1.1.0
decorator==5.0.9
decorator==5.1.0
idna==3.2
lxml==4.6.3
pycparser==2.20
Expand All @@ -15,4 +15,4 @@ requests==2.26.0
six==1.16.0
tornado==6.1
tzlocal==3.0
urllib3==1.26.6
urllib3==1.26.7
13 changes: 6 additions & 7 deletions src/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import logging.config
import os
from os.path import dirname
from pathlib import Path

import yaml

from resources.properties import LOGS_FOLDER, LOGS_LEVEL, LOGS_MODE

file_path = os.path.abspath(__file__)
parent_folder = dirname(file_path)
path_log_folder = os.path.join(parent_folder, '..', LOGS_FOLDER)
file_path = Path(__file__).absolute()
root_folder = file_path.parent.parent
path_log_folder = Path(root_folder).joinpath(LOGS_FOLDER)

if not os.path.exists(path_log_folder):
try:
Expand All @@ -20,14 +20,13 @@
except OSError:
print(f"Creation of the log directory '{path_log_folder}' failed")

path_log_config_file = os.path.join(parent_folder, '..', 'resources', 'log.yaml')
path_log_config_file = Path(root_folder).joinpath('resources').joinpath('log.yaml')

if os.path.exists(path_log_config_file):
if os.path.isfile(path_log_config_file):
with open(path_log_config_file, 'r') as config_file:
with open(path_log_config_file, 'rt') as config_file:
config = yaml.safe_load(config_file.read())
logging.config.dictConfig(config)
config_file.close()
else:
print(f"The path to the log configuration file must be a file not a directory: {path_log_config_file}")
else:
Expand Down

0 comments on commit 090dd1d

Please sign in to comment.