Spaces:
Running
Running
zach
commited on
Commit
·
f477f87
1
Parent(s):
abaeb0b
Update .env.example and no longer enable debug logging based on env variable and base it on use of 'dev' environment instead.
Browse files- .env.example +4 -2
- src/config.py +6 -8
.env.example
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
-
#
|
2 |
-
|
|
|
|
|
3 |
|
4 |
# API Keys
|
5 |
HUME_API_KEY=YOUR_HUME_API_KEY
|
|
|
1 |
+
# Environment variables for local development ("dev" environment).
|
2 |
+
# These values are loaded from the .env file when running locally.
|
3 |
+
# In production ("prod" environment), environment variables must be set in the system
|
4 |
+
# and will not be loaded from this file.
|
5 |
|
6 |
# API Keys
|
7 |
HUME_API_KEY=YOUR_HUME_API_KEY
|
src/config.py
CHANGED
@@ -4,9 +4,10 @@ config.py
|
|
4 |
Global configuration and logger setup for the project.
|
5 |
|
6 |
Key Features:
|
7 |
-
-
|
|
|
8 |
- Configures the logger for consistent logging across all modules.
|
9 |
-
- Dynamically
|
10 |
"""
|
11 |
|
12 |
# Standard Library Imports
|
@@ -33,12 +34,8 @@ if APP_ENV == "dev":
|
|
33 |
print("Warning: .env file not found. Using system environment variables.")
|
34 |
|
35 |
|
36 |
-
# Enable
|
37 |
-
|
38 |
-
if debug_raw not in {"true", "false"}:
|
39 |
-
print(f'Warning: Invalid DEBUG value "{debug_raw}". Defaulting to "false".')
|
40 |
-
DEBUG = debug_raw == "true"
|
41 |
-
|
42 |
|
43 |
# Configure the logger
|
44 |
logging.basicConfig(
|
@@ -46,6 +43,7 @@ logging.basicConfig(
|
|
46 |
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
47 |
)
|
48 |
logger: logging.Logger = logging.getLogger("tts_arena")
|
|
|
49 |
logger.info(f'Debug mode is {"enabled" if DEBUG else "disabled"}.')
|
50 |
|
51 |
if DEBUG:
|
|
|
4 |
Global configuration and logger setup for the project.
|
5 |
|
6 |
Key Features:
|
7 |
+
- Uses environment variables defined in the system (Docker in production).
|
8 |
+
- Loads a `.env` file only in development to simulate production variables locally.
|
9 |
- Configures the logger for consistent logging across all modules.
|
10 |
+
- Dynamically enables DEBUG logging in development and INFO logging in production (unless overridden).
|
11 |
"""
|
12 |
|
13 |
# Standard Library Imports
|
|
|
34 |
print("Warning: .env file not found. Using system environment variables.")
|
35 |
|
36 |
|
37 |
+
# Enable debug mode if in development (or if explicitly set in env variables)
|
38 |
+
DEBUG = APP_ENV == "dev" or os.getenv("DEBUG", "false").lower() == "true"
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Configure the logger
|
41 |
logging.basicConfig(
|
|
|
43 |
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
44 |
)
|
45 |
logger: logging.Logger = logging.getLogger("tts_arena")
|
46 |
+
logger.info(f'App running in "{APP_ENV}" mode.')
|
47 |
logger.info(f'Debug mode is {"enabled" if DEBUG else "disabled"}.')
|
48 |
|
49 |
if DEBUG:
|