Skip to content

Commit

Permalink
Fix 8
Browse files Browse the repository at this point in the history
  • Loading branch information
vg12345 committed May 15, 2024
1 parent 7199f4b commit 2b8d6f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions plugins/pdr_deterministic_plugin/tests/exclude_list_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def test_get_from_empty_exclude_list():
"""
print("Test 5")

filename = os.path.basename(Constants.LOG_FILE)
lod_file = os.path.join(tempfile.gettempdir(), filename)
log_name = os.path.basename(Constants.LOG_FILE)
log_path = os.path.join(tempfile.gettempdir(), log_name)

logger = create_logger(lod_file)
logger = create_logger(log_path)
exclude_list = ExcludeList(logger)
items = exclude_list.items()
assert not items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,26 @@
from utils.utils import Utils


def create_logger(file):
def create_logger(log_file):
"""
create a logger to put all the data of the server action
:param file: name of the file
:return:
"""
format_str = "%(asctime)-15s UFM-PDR_deterministic-plugin-{0} Machine: {1} %(levelname)-7s: %(message)s".format(file,'localhost')
log_name = Constants.LOG_FILE
if not os.path.exists(log_name):
os.makedirs('/'.join(log_name.split('/')[:-1]), exist_ok=True)
logger = logging.getLogger(log_name)
format_str = "%(asctime)-15s UFM-PDR_deterministic-plugin-{0} Machine: {1} %(levelname)-7s: %(message)s".format(log_file,'localhost')
if not os.path.exists(log_file):
os.makedirs('/'.join(log_file.split('/')[:-1]), exist_ok=True)
logger = logging.getLogger(log_file)

logging_level = logging.getLevelName(Constants.log_level) \
if isinstance(Constants.log_level, str) else Constants.log_level

logging.basicConfig(format=format_str,level=logging_level)
rotateHandler = RotatingFileHandler(log_name,maxBytes=Constants.log_file_max_size,
rotate_handler = RotatingFileHandler(log_file,maxBytes=Constants.log_file_max_size,
backupCount=Constants.log_file_backup_count)
rotateHandler.setLevel(Constants.log_level)
rotateHandler.setFormatter(logging.Formatter(format_str))
logger.addHandler(rotateHandler)
rotate_handler.setLevel(Constants.log_level)
rotate_handler.setFormatter(logging.Formatter(format_str))
logger.addHandler(rotate_handler)
return logger


Expand Down

0 comments on commit 2b8d6f0

Please sign in to comment.