Skip to content

Redirect SOFA logs to Python's sys.stdout using a custom PythonMessageHandler#576

Merged
fredroy merged 4 commits intosofa-framework:masterfrom
alxbilger:pythonmessagehandler
Feb 13, 2026
Merged

Redirect SOFA logs to Python's sys.stdout using a custom PythonMessageHandler#576
fredroy merged 4 commits intosofa-framework:masterfrom
alxbilger:pythonmessagehandler

Conversation

@alxbilger
Copy link
Contributor

SOFA log messages were not displayed in a Jupyter notebook. The reason is explained here. pybind11 has a way to redirect std::cout/std::cerr to Python's sys.stdout: https://pybind11.readthedocs.io/en/stable/advanced/pycpp/utilities.html

Note that SofaRuntime.init() must be called in order to enable this redirection.

Result in a notebook:

image

@alxbilger alxbilger force-pushed the pythonmessagehandler branch from a776468 to 60110c3 Compare February 6, 2026 07:22
@fredroy fredroy merged commit 959b4cd into sofa-framework:master Feb 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants