raisim::RaiSimMsg
class · #include <raisim/raisim_message_logger.hpp>
Message printer behind the RSINFO / RSWARN / RSFATAL macros (raisim_message.hpp). Messages go to std::cout with a time stamp and the source location. A fatal message then calls the fatal callback: the calling thread's callback if one is installed, otherwise the global callback, which defaults to std::exit(1). Execution continues after RSFATAL if the callback returns, so a custom callback should normally throw.
Public types
FatalCallback
using FatalCallback = std::function<void()>Callback invoked after a fatal message is printed.
Public member functions
stream
void stream(
const char *file,
int line,
std::stringstream &msg,
int severity)Format and print a message with filename/line and severity.
Parameters
| Parameter | Description |
|---|---|
file (in) | Source file path. |
line (in) | Source line number. |
msg (in) | Message stream to print. |
severity (in) | Severity level (RSEVERITY_*). |
Static member functions
setFatalCallback static
static void setFatalCallback(FatalCallback fatalCallback)Set the global callback invoked on fatal messages (used by threads without their own callback).
Parameters
| Parameter | Description |
|---|---|
fatalCallback (in) | Callback function. An empty function restores the default std::exit(1). |
setThreadFatalCallback static
static FatalCallback setThreadFatalCallback(FatalCallback fatalCallback)Install a callback for the calling thread and return its previous callback. It takes precedence over the global callback on this thread. Callbacks are kept per thread id, so remove it (pass an empty function, or use ScopedRaiSimFatalCallback) before the thread exits; otherwise a later thread that is given the same id inherits it.
Parameters
| Parameter | Description |
|---|---|
fatalCallback (in) | callback for this thread; an empty function removes it |
Returns the previous callback of this thread (empty if none)