robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
156 stars 65 forks source link

Provide support to redirect iDynTree errors to a specified function #1064

Open traversaro opened 1 year ago

traversaro commented 1 year ago

At the moment, iDynTree prints all its error/messages to std::cout/std::cerr or stdout/stderr. This works fine if one uses iDynTree just in a terminal application, but can be problematic if iDynTree is used in a GUI application (for example, as part of a plugin), as in that case the iDynTree error messages should be redirected somewhere else, where the user/developer can see them. In theory std::cout and std::cerr can also be redirected (see https://stackoverflow.com/questions/10150468/how-to-redirect-cin-and-cout-to-files), but that it a global operation that may affect also non-iDynTree messages.

To support the use cases in which iDynTree messages want to be redirected, we could use spdlog as we did for other libraries we developed in the lab, however if anyone has some better idea please comment, thanks!

cc @Nicogene