Environment variables¶
Variables explained¶
Level (
LOGGER_LEVEL)It uses the constants of logging
Determines the minimum level that logs will need to be logged
Accepted values:
NOTSET,DEBUG,INFO,WARNING,ERROR,FATAL.
Handlers
Determines the outputs enabled for the logs
Console handler variable (
C_HANDLER_ENABLED) enables the output in the terminalFile handler variable (
F_HANDLER_ENABLED) enables the output to a fileBoth variables are boolean (
TRUEorFALSE. It isn’t case sensitive, soTRUE = true = True)
Name |
Values accepted (*) |
Defaults |
|---|---|---|
CH_ENABLED |
TRUE, FALSE |
TRUE |
FH_ENABLED |
TRUE, FALSE |
FALSE |
LOGGER_LEVEL |
NOTSET, DEBUG, INFO, WARNING, ERROR, FATAL |
INFO |
(*) = Case-insensitive. For example INFO is the same as info, Info, etc.
Custom Values¶
After the variables are loaded into the environment, you can load them into the logger configuration like this:
from logger import LoggerConfig
LoggerConfig.load_env_vars()
If you want to use a file like .env in your root folder, first you
need to load them into your environment, with something like
python-dotenv. Anyways,
this is made by batch and if you
use that library, it will load your configuration from .env if you
put custom values there.