Skip to content

Commit 8479649

Browse files
committed
refactor: reuse _enable_execution_id_logging from main module
1 parent c473a2d commit 8479649

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/functions_framework/aio/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from cloudevents.http.event import CloudEvent
2929

3030
from functions_framework import _function_registry, execution_id
31+
from functions_framework import _enable_execution_id_logging
3132
from functions_framework.exceptions import (
3233
FunctionsFrameworkException,
3334
MissingSourceException,
@@ -65,9 +66,7 @@ async def _crash_handler(request, exc):
6566
f"Exception on {request.url.path} [{request.method}]\n{tb_text}".rstrip()
6667
)
6768

68-
# Context should still be available since we don't reset on exception
6969
if _enable_execution_id_logging():
70-
# Output as JSON so LoggingHandlerAddExecutionId can process it
7170
log_entry = {"message": error_msg, "levelname": "ERROR"}
7271
logger.error(json.dumps(log_entry))
7372
else:
@@ -181,11 +180,6 @@ async def _handle_not_found(request: Request):
181180
raise HTTPException(status_code=404, detail="Not Found")
182181

183182

184-
def _enable_execution_id_logging():
185-
# Based on distutils.util.strtobool
186-
truthy_values = ("y", "yes", "t", "true", "on", "1")
187-
env_var_value = os.environ.get("LOG_EXECUTION_ID")
188-
return env_var_value in truthy_values
189183

190184

191185
def _configure_app_execution_id_logging():

0 commit comments

Comments
 (0)