Added common module

This commit is contained in:
Szirtesi,Tamás Gábor 2023-10-09 14:24:36 +02:00
parent 03bc4bed24
commit 54663bdf48

25
hc_spider/common.py Normal file
View File

@ -0,0 +1,25 @@
import json
from functools import lru_cache
import logging
CONFIG_FILE = "config.json"
@lru_cache
def load_config() -> dict:
with open(CONFIG_FILE) as f:
config = json.load(f)
return config
def get_logger() -> logging.Logger:
logger = logging.getLogger("hc_spider")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
formatter = logging.Formatter(
'%(asctime)s %(process)d %(processName)s %(thread)d %(threadName)s %(module)s %(levelname)s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger