I currently have:
FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
logging.basicConfig(format=FORMAT, datefmt='%d/%m/%Y %H:%M:%S', filename=LOGFILE, level=getattr(logging, options.loglevel.upper()))
... which works great, however I'm trying to do:
FORMAT = '%(MYVAR)s %(asctime)s - %(levelname)s - %(message)s'
and that just throws keyerrors, even though MYVAR is defined.
Is there a workaround? MYVAR is a constant, so it would be a shame of having to pass it everytime I invoke the logger.
Thank you!
MYVARis going to have always the same value, isn'tFORMAT = '{} %(asctime)s - %(levelname)s - %(message)s'.format(MYVAR)a possible alternative?