Closed TobKra96 closed 3 years ago
Something like this. It has 5 rolling logs up to 5mb
each, and outputs to console.
from logging.handlers import RotatingFileHandler
import logging
logging.basicConfig(handlers=[
RotatingFileHandler('../../.mlsc/mlsc.log', mode='a', maxBytes=5 * 1024 * 1024, backupCount=5, encoding='utf-8'),
logging.StreamHandler()
],
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y.%m.%d %H:%M:%S',
level=logging.INFO
)
logger = logging.getLogger('dev')
logger.setLevel(logging.DEBUG)
And to disable logging to the console, for example with a checkbox:
logger.StreamHandler(stream=None)
Check if we can use a logging library, that can save rolling logs, manage the console output. Convert all print commands to the logging mechanism.