@@ -7,27 +7,38 @@ namespace fs = std::filesystem;
7
7
8
8
int main ()
9
9
{
10
+ // Retrieve the path where the Python scripts to use are located (can provide multiple locations).
10
11
std::string path = fs::current_path ();
11
12
std::vector<std::string> python_path = { path + " /src/" };
13
+ // Provide the Python scripts to include.
12
14
std::vector<std::string> python_scripts = {" example_moniloggers" };
15
+ // Name of the interface module (here, an embedded module declared above) exposing the execution context of the application.
13
16
std::string interface_module = " example_interface" ;
17
+ // Initialization function for the interface module.
14
18
std::function<void (pybind11::module_, pybind11::object)> interface_module_initializer =
15
19
[](pybind11::module_ iterativeheatequation_module, pybind11::object context_class) { };
16
20
21
+ // Define base execution events emitted by the application, to which moniloggers can register.
17
22
MoniLog::register_base_events ({
18
23
{" SomeEvent" , 0 },
19
24
{" SomeOtherEvent" , 1 }
20
25
});
21
26
27
+ // Define a composite event, emitted when either of its triggering events are emitted.
22
28
MoniLog::register_composite_event (" SomeCompositeEvent" , {" SomeEvent" , " SomeOtherEvent" });
23
29
30
+ // Instantiating the execution context accessible from Python.
24
31
std::shared_ptr<MoniLog::MoniLogExecutionContext> ctx (new MoniLog::MoniLogExecutionContext ());
25
32
33
+ // Bootstrapping monilog, consisting mainly of starting the Python interpreter, initializing
34
+ // the monilog module, and evaluating the provided scripts.
26
35
MoniLog::bootstrap_monilog (python_path, python_scripts, interface_module, interface_module_initializer);
27
36
37
+ // Emitting some base events, triggering the registered moniloggers.
28
38
MoniLog::trigger (0 , ctx);
29
39
MoniLog::trigger (1 , ctx);
30
40
41
+ // Emitting a composite event (can also emit base event by name).
31
42
MoniLog::trigger (" SomeCompositeEvent" , ctx);
32
43
33
44
}
0 commit comments