1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-05-30 07:09:39 +03:00

EDMCLogging: flake8 cleanup

* import order.
* Sanitise RotatingFileHandler() call formatting.
This commit is contained in:
Athanasius 2020-09-07 15:09:11 +01:00
parent 30c9dbefc1
commit f85371ac99

View File

@ -7,16 +7,16 @@ members on the logging.LogRecord instance for use in logging.Formatter()
strings. strings.
""" """
# So that any warning about accessing a protected member is only in one place.
from sys import _getframe as getframe
import inspect import inspect
import logging import logging
import logging.handlers import logging.handlers
import pathlib import pathlib
import tempfile import tempfile
# So that any warning about accessing a protected member is only in one place.
from sys import _getframe as getframe
from typing import Tuple from typing import Tuple
from config import config, appname from config import appname, config
# TODO: Tests: # TODO: Tests:
# #
@ -90,13 +90,14 @@ class Logger:
logfile_rotating.mkdir(exist_ok=True) logfile_rotating.mkdir(exist_ok=True)
logfile_rotating = logfile_rotating / f'{logger_name}.log' logfile_rotating = logfile_rotating / f'{logger_name}.log'
_MAXBYTES = 1024 * 1024 # 1MiB self.logger_channel_rotating = logging.handlers.RotatingFileHandler(
_BACKUPS = 10 logfile_rotating,
self.logger_channel_rotating = logging.handlers.RotatingFileHandler(logfile_rotating, mode='a', mode='a',
maxBytes=_MAXBYTES, maxBytes=1024 * 1024, # 1MiB
backupCount=_BACKUPS, backupCount=10,
encoding='utf-8', encoding='utf-8',
delay=False) delay=False
)
# Do *NOT* set here, want logger's level to work: self.logger_channel_rotating.setLevel(loglevel) # Do *NOT* set here, want logger's level to work: self.logger_channel_rotating.setLevel(loglevel)
self.logger_channel_rotating.setFormatter(self.logger_formatter) self.logger_channel_rotating.setFormatter(self.logger_formatter)
self.logger.addHandler(self.logger_channel_rotating) self.logger.addHandler(self.logger_channel_rotating)