mirror of https://github.com/kortix-ai/suna.git
chore(logger): add dynamic logging level configuration based on environment variable
This commit is contained in:
parent
fbb6838ce6
commit
2b7c9856c1
|
@ -1,6 +1,9 @@
|
|||
import structlog, logging, os
|
||||
|
||||
ENV_MODE = os.getenv("ENV_MODE", "LOCAL")
|
||||
LOGGING_LEVEL = logging.getLevelNamesMapping().get(
|
||||
os.getenv("LOGGING_LEVEL", "DEBUG").upper(), logging.DEBUG
|
||||
)
|
||||
|
||||
renderer = [structlog.processors.JSONRenderer()]
|
||||
if ENV_MODE.lower() == "local".lower() or ENV_MODE.lower() == "staging".lower():
|
||||
|
@ -23,6 +26,7 @@ structlog.configure(
|
|||
*renderer,
|
||||
],
|
||||
cache_logger_on_first_use=True,
|
||||
wrapper_class=structlog.make_filtering_bound_logger(LOGGING_LEVEL),
|
||||
)
|
||||
|
||||
logger: structlog.stdlib.BoundLogger = structlog.get_logger(level=logging.DEBUG)
|
||||
logger: structlog.stdlib.BoundLogger = structlog.get_logger()
|
||||
|
|
Loading…
Reference in New Issue