openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
138 stars 51 forks source link

Handle stdout & stderr messages more pythonic #192

Open C0nsultant opened 6 years ago

C0nsultant commented 6 years ago

Currently (see #191), all output generated by the C++ API is piped to std::cout/std::cerr.

For ideal Python support - which includes pythonic output and logging - one would need to capture the output from C++ and redirect it to message handling facilities in python. This could be Python's stdout/stderr and logging on a very basic level or some advanced implementation that can differentiate and mute multiple levels of output (as present for example in PIConGPU).

ax3l commented 6 years ago

:+1: Also relevant for the notebook because otherwise we will write to the running kernel's log instead of to the frontend the user is seeing.

Fun fact: throws are easy to pythonize.

Implementation idea: probably define in the series a method to select the default out/err[/log] channel and alle linked objects inherit it. In the Python API, we can set the python-method on init automatically during the binds.