tklab-tud / uscxml

SCXML interpreter and transformer/compiler written in C/C++ with bindings to Java, C#, Python and Lua
Other
106 stars 54 forks source link

Question: logging to file using interpreter monitor and logger #190

Open crichardson332 opened 4 years ago

crichardson332 commented 4 years ago

I'm trying to figure out how to log state transitions to a file, preferably using fstream. I see that there are logging classes that can log to streams, but I don't know exactly how to implement that. I'm able to get a logger that prints to std::cout, but I need to pipe it to a file instead. Is there an example somewhere on how to do this?

sradomski commented 4 years ago

You are supposed to pass a Logger via the ActionLanguage to the interpreter.

crichardson332 commented 4 years ago

Is there an example or code snippet somewhere I can reference? I'm not clear on the API.

crichardson332 commented 4 years ago

What I want to do is something like this uscxml::Logger mylogger = std::make_shared(new uscxml::StdOutLogger) except I will replace StdOutLogger with my own custom implementation of a logger. But I'm getting the following error:

In file included from /usr/local/include/uscxml/interpreter/StdOutLogger.h:23:0,
                 from ../test/test_uscxml.cpp:41:
/usr/local/include/uscxml/interpreter/LoggingImpl.h:23:10: fatal error: uscxml/config.h: No such file or directory
 #include "uscxml/config.h"
          ^~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.

This happens when my code has #include "uscxml/interpreter/StdOutLogger.h".

It looks like config.h exists in my build tree but not the install tree. Is there a build flag I'm missing?