Skip to content

Commit ff785d2

Browse files
updated code blank value fix
1 parent b7ee1e0 commit ff785d2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/api/app.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@
2626
# Load environment variables
2727
load_dotenv()
2828

29+
30+
def _get_env_or_default(key: str, default: str) -> str:
31+
"""Get environment variable with fallback for empty/whitespace values."""
32+
value = os.getenv(key)
33+
return value.strip().upper() if value and value.strip() else default.upper()
34+
35+
2936
# Configure logging
3037
# Basic application logging (default: INFO level)
31-
AZURE_BASIC_LOGGING_LEVEL = os.getenv("AZURE_BASIC_LOGGING_LEVEL", "INFO").upper()
38+
AZURE_BASIC_LOGGING_LEVEL = _get_env_or_default("AZURE_BASIC_LOGGING_LEVEL", "INFO")
3239
# Azure package logging (default: WARNING level to suppress INFO)
33-
AZURE_PACKAGE_LOGGING_LEVEL = os.getenv("AZURE_PACKAGE_LOGGING_LEVEL", "WARNING").upper()
40+
AZURE_PACKAGE_LOGGING_LEVEL = _get_env_or_default("AZURE_PACKAGE_LOGGING_LEVEL", "WARNING")
3441
# Azure logging packages (default: empty list)
35-
azure_logging_packages_env = os.getenv("AZURE_LOGGING_PACKAGES")
36-
AZURE_LOGGING_PACKAGES = azure_logging_packages_env.split(",") if azure_logging_packages_env else []
42+
AZURE_LOGGING_PACKAGES = [
43+
pkg.strip() for pkg in os.getenv("AZURE_LOGGING_PACKAGES", "").split(",") if pkg.strip()
44+
]
3745

3846
# Basic config: logging.basicConfig(level=logging.INFO)
3947
logging.basicConfig(

0 commit comments

Comments
 (0)