Configuring Logging
-
The level of logs displayed by
mailbagitis based on an environment variableMAILBAGIT_LOG_LEVEL. -
Log levels are available in the following order :
NOTSET,DEBUG,INFO,WARN,ERROR, andCRITICAL. For example, when theMAILBAGIT_LOG_LEVELisDEBUG,mailbagitdisplays logs of all levels. And whenMAILBAGIT_LOG_LEVELisWARN, it displays logs of levelWARNand above. i.e.WARN,ERROR, orCRITICAL. -
If no
MAILBAGIT_LOG_LEVELenvironment variable is set,mailbagitwill default toWARN.
Unix example:
export MAILBAGIT_LOG_LEVEL=info
echo $MAILBAGIT_LOG_LEVEL
> info
Windows Powershell example:
$env:MAILBAGIT_LOG_LEVEL='debug'
$env:MAILBAGIT_LOG_LEVEL
> debug
On Windows, you can also set environment variables by searching “edit environment variable”.
Example of the logger initiation and usage in Python:
from structlog import get_logger
import mailbagit.loggerx
loggerx.configure()
log = get_logger()
log.error("Error message here")
log.info("Information message here")