Skip to content

Commit 31afaad

Browse files
committed
[SofaPython3] Activate 'per component' logging by default when using the Sofa binding
The message pipeline in sofa is rather complex and by default the components does not stores the messages (info, warning, error) that are emitted. In runSofa the message pipeline is configured so keep track of eache messages received on a per object basis. This is done by registering a dedicated message handler in the message pipeline. In this PR we active this behavior by default in the Sofa python module so the behavior is consistant with what happens in Sofa.
1 parent 0a941c5 commit 31afaad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bindings/Sofa/src/SofaPython3/Sofa/Core/Submodule_Core.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ along with sofaqtquick. If not, see <http://www.gnu.org/licenses/>.
2626
********************************************************************/
2727

2828

29+
#include <sofa/helper/logging/Messaging.h>
30+
using sofa::helper::logging::Message;
31+
32+
#include <sofa/core/logging/PerComponentLoggingMessageHandler.h>
33+
using sofa::helper::logging::MessageDispatcher;
34+
using sofa::helper::logging::MainPerComponentLoggingMessageHandler;
35+
36+
2937
#include <sofa/core/objectmodel/BaseNode.h>
3038
#include <sofa/core/objectmodel/BaseContext.h>
3139
#include <sofa/core/behavior/BaseForceField.h>
@@ -105,6 +113,8 @@ PYBIND11_MODULE(Core, core)
105113
#Sofa.Core.WriteAccessor
106114
)doc";
107115

116+
MessageDispatcher::addHandler(&MainPerComponentLoggingMessageHandler::getInstance()) ;
117+
108118
moduleAddPythonScriptEvent();
109119
moduleAddDataDict(core);
110120
moduleAddDataDictIterator(core);

0 commit comments

Comments
 (0)