33 lines
748 B
Python
33 lines
748 B
Python
from dotenv import load_dotenv
|
|
import logging
|
|
from configparser import ConfigParser
|
|
from pathlib import Path
|
|
from typing import Literal
|
|
|
|
|
|
# load default values
|
|
config = ConfigParser()
|
|
config.read(Path(__file__).parent / 'defaults.ini')
|
|
LOGGER_LEVEL = config.get('main', 'logger_level')
|
|
|
|
|
|
def setup_logging(
|
|
logger_level: str = LOGGER_LEVEL
|
|
):
|
|
fmt = (
|
|
'%(asctime)s | '
|
|
'%(levelname)s | '
|
|
'%(filename)s | '
|
|
'%(funcName)s | '
|
|
'%(message)s'
|
|
)
|
|
datefmt = '%Y-%m-%d %H:%M:%S'
|
|
level = getattr(logging, logger_level.upper())
|
|
logging.basicConfig(format=fmt, datefmt=datefmt, level=level)
|
|
logging.debug('finished')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
load_dotenv('dev.env')
|
|
setup_logging()
|