Skip to content

Commit

Permalink
feat: add log level config
Browse files Browse the repository at this point in the history
  • Loading branch information
deryrahman committed Apr 23, 2024
1 parent 6c96b67 commit 084e512
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion task/bq2bq/executor/bumblebee/log.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import sys
import logging
import os

def get_log_level():
log_level = str(os.environ.get("LOG_LEVEL", default="INFO")).upper()
return log_level if log_level in logging._nameToLevel else "INFO"

def get_logger(name: str):
logger = logging.getLogger(name)
logformat = "[%(asctime)s] %(levelname)s:%(name)s: %(message)s"
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout,
level = logging.getLevelNamesMapping().get(get_log_level())
logging.basicConfig(level=level, stream=sys.stdout,
format=logformat, datefmt="%Y-%m-%d %H:%M:%S")

return logger

0 comments on commit 084e512

Please sign in to comment.