Currently, there is no way to log from Python to the FMI interface.
A method, say log(category, msg) could be added to the fmislave base class.
Proposed implementation
One way to do this is:
How to pass messages from Python to C
Store unread log messages in a queue in Python.
Implement method in baseclass for reading these.
Call method from C code and log using logger callback
Adding log categories to model description
Manual approach
Add a method to declare categories to baseclass:
declare_log_category('autograd error')
Then to use:
self.log('autograd error', 'derivative is undefined')
Automatic discovery of log categories by code inspection
Python standard library has methods to grab source code and parse.
inspect.getsource(...)
ast.parse(...)
As such it would be possible to inspect the code for log statements and their categories.
This would also be useful to warn if a category is missing.
Questions
Use of Python logging lib
Investigate if it makes sense to use Pythons built in logging for this.
The benefit of this would familiarity and the possibility of passing log messages from third party tools through FMI interface.
Currently, there is no way to log from Python to the FMI interface. A method, say log(category, msg) could be added to the fmislave base class.
Proposed implementation
One way to do this is:
How to pass messages from Python to C
Adding log categories to model description
Manual approach
Add a method to declare categories to baseclass:
Then to use:
Automatic discovery of log categories by code inspection
Python standard library has methods to grab source code and parse.
As such it would be possible to inspect the code for log statements and their categories. This would also be useful to warn if a category is missing.
Questions
Use of Python logging lib
Investigate if it makes sense to use Pythons built in logging for this. The benefit of this would familiarity and the possibility of passing log messages from third party tools through FMI interface.
https://docs.python.org/3/library/logging.html
stdout and stderr
What should happen to print statements?