26 lines
600 B
Python

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