From 084e512ee61da79e2c995a745b34637fe5bb15fd Mon Sep 17 00:00:00 2001 From: Dery Rahman Ahaddienata Date: Tue, 23 Apr 2024 14:51:24 +0700 Subject: [PATCH] feat: add log level config --- task/bq2bq/executor/bumblebee/log.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/task/bq2bq/executor/bumblebee/log.py b/task/bq2bq/executor/bumblebee/log.py index 9343af3..2943533 100644 --- a/task/bq2bq/executor/bumblebee/log.py +++ b/task/bq2bq/executor/bumblebee/log.py @@ -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