ePrivacy and GPDR Cookie Consent by Cookie Consent


The logger is used for recording data inside the state machine at runtime. It is useful for debugging purposes and to get an insight into the running the state machine.

Starting the log

Logging is enabled by getting a reference to the log manager (a singleton), setting a log level for the messages and by adding a logger (file logger, console logger, custom logger).

Now simply start the log manager and it will launch a new thread. The logging thread logs to the specified locations including: the console, to file, syslog, etc...

Call run() to begin.

Stopping the log

When the logger is done being used, call the halt() method. This is not enough to stop the logger though. After halt(), the user has to call join() on the logger to finally join the logging thread.

From version 0.7.0, yasmine provides the convenience method halt_and_join() for stopping and joining the logger in a single step.

The two step stopping procedure is useful if you have other threads that need to be stopped. Thus you can first trigger to stop all threads and then join them. This will reduce shut down time.

Custom loggers

You can write custom loggers to log to new target locations (syslog, Windows event log, ...) or to forward the yasmine log messages to your own logging system. To do this implement the logger interface.


There are two macros available for using the logger: SX_LOG and SX_LOG_HEX.

SX_LOG is for text messages with placeholder replacement. It generates one line in the log.

SX_LOG_HEX is a logging macro that can log hex editor style. It's useful to display binary data.


An example is available on the hello_yasmine project page.

Log levels






Used to turn logging off. This value is set as default when the log manager is created.



Error in internal logic that we cannot recover from. In DEBUG mode assert is called next, In RELEASE mode a program crash can be expected next.



Internal error which makes it impossible for the state machine to continue working. The program state is valid though and thus the program can continue running.



An error occurred (e.g. defect in defined state machine, event cannot be fired because state machine is not running).



An unusual condition occurred that could be an error (e.g. a timed event could not be cancelled, this could be a logic error or the event might have just fired).



Important information for the user about the state machine.



Information for the user about the state machine.



Information about internal processes in the state machine. Usually only useful for developers of yasmine.



Detailed information about internal processes in the state machine. Usually only useful for developers of yasmine.

A smaller index implies a higher priority.

Disabling logging

In order to completely disable logging, compile the library with SX_NO_LOGGING defined. Then the log macros expands to nothing and thus no code is generated and no run-time overhead occurs.