Skip to content

Commit 3ca0727

Browse files
ImTotemclaude
andcommitted
fix(slack): use root logger for 500 error alerts
Exception handler used named logger which may not propagate to root logger's SlackHandler. Use logging.getLogger() (root) directly to guarantee Slack notifications for unhandled exceptions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b8a20de commit 3ca0727

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/bcsd_api/exception/handlers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from .base import AppException
77

8-
logger = logging.getLogger(__name__)
8+
logger = logging.getLogger("bcsd_api.error")
99

1010

1111
def register_handlers(app: FastAPI) -> None:
@@ -16,6 +16,8 @@ async def _handle(request: Request, exc: AppException) -> JSONResponse:
1616

1717
@app.exception_handler(Exception)
1818
async def _unhandled(request: Request, exc: Exception) -> JSONResponse:
19-
logger.error("%s %s: %s", request.method, request.url.path, exc, exc_info=exc)
19+
logging.getLogger().error(
20+
"%s %s: %s", request.method, request.url.path, exc, exc_info=exc,
21+
)
2022
body = {"error_code": "INTERNAL_ERROR", "message": "internal server error"}
2123
return JSONResponse(status_code=500, content=body)

0 commit comments

Comments
 (0)