class ContextFilter(logging.Filter):
    """
    This is a filter which injects contextual information into the log.
    """

def filter(self, record):
    record.MYVAR = MYVAR
return True
FORMAT = '%(MYVAR)s %(asctime)s - %(levelname)s - %(message)s'
logging.basicConfig(format=FORMAT, datefmt='%d/%m/%Y %H:%M:%S')
logger = logging.getLogger(__name__)
logger.addFilter(ContextFilter())
logger.warning("'Twas brillig, and the slithy toves")
Как вводить переменные в форматтер логгера?