From 55affb35017c5a343cdd04b4e14ae0f5d6c24f94 Mon Sep 17 00:00:00 2001 From: Ege Kocabas <48245934+egekocabas@users.noreply.github.com> Date: Wed, 10 Jan 2024 01:32:20 +0100 Subject: [PATCH] refactor: Support different log levels for different environments (#28) --- parma_mining/github/api/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/parma_mining/github/api/main.py b/parma_mining/github/api/main.py index 0100fa2..04eb6a9 100644 --- a/parma_mining/github/api/main.py +++ b/parma_mining/github/api/main.py @@ -15,7 +15,15 @@ ) from parma_mining.github.normalization_map import GithubNormalizationMap -logging.basicConfig(level=logging.INFO) +env = os.getenv("env", "local") + +if env == "prod": + logging.basicConfig(level=logging.INFO) +elif env in ["staging", "local"]: + logging.basicConfig(level=logging.DEBUG) +else: + logging.warning(f"Unknown environment '{env}'. Defaulting to INFO level.") + logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__)