Skip to content

Commit

Permalink
Feature/refactor (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffwhittington authored Apr 27, 2023
1 parent 5170348 commit b996ff4
Show file tree
Hide file tree
Showing 9 changed files with 389 additions and 321 deletions.
6 changes: 6 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import yaml
from yaml.loader import SafeLoader

relay_config = {}
with open("config.yaml", "r") as f:
relay_config = yaml.load(f, Loader=SafeLoader)
20 changes: 20 additions & 0 deletions log_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import logging
from config import relay_config


def get_logger(name):
logger = logging.getLogger(name=name)
log_level = getattr(logging, relay_config["logging"]["level"].upper())

logger.setLevel(log_level)
logger.propagate = False # Add this line to prevent double logging

handler = logging.StreamHandler()
handler.setFormatter(
logging.Formatter(
fmt=f"%(asctime)s %(levelname)s:%(name)s:%(message)s",
datefmt="%Y-%m-%d %H:%M:%S %z",
)
)
logger.addHandler(handler)
return logger
Loading

0 comments on commit b996ff4

Please sign in to comment.