Always using stdout and stderr.


Logging is synchronous if the process has an attached terminal. This is normally what you want if you’re launching the program from the command-line.

Loggig is asynchronous if the process has no attached terminal. This benefits the predictability of latency of the running process because it can offload the writing of the message to a secondary thread.


Logging capabilities are accessed through macros. This is done to capture filename and line number at the point where the log message is being generated.

Logging must identify the severity

  • INFO




In particular, a fatal log message will

  • try to flush log buffers,

  • write a backtrace to stderr,

  • abort the running process and

  • maybe create a core dump.

The log message itself is being generated by fmt.

Some examples

2LOG(WARNING)("Latency {} exceeds the threshold of {}", latency, threshold);
3LOG(ERROR)(R"(Invalid key="{}")", key);

Verbosity can be controlled by setting the ROQ_v environment variable (the default value is 0 (zero)).

Some examples

1VLOG(0)("Same as INFO");
2VLOG(1)("Will log when ROQ_v >= 1");
3VLOG(2)("Will log when ROQ_v >= 2");

Debug logging will only be active for debug builds, i.e. when NDEBUG has not been defined.

Some examples

1DLOG(INFO)("Will log for debug builds, only");
2DLOG(WARNING)("Will also only log for debug builds");

Conditional logging is easy, just append _IF and add an expression.

Some examples

1LOG_IF(INFO, success)("Success!");
2VLOG_IF(1, value > 3)("Value is larger than three");


class roq::Service

Convenience class to wrap roq::Logger, absl::flags, etc.

Public Functions

int run()

The main function.


class roq::Tool

Convenience class to wrap roq::Logger, absl::flags, etc.

Public Functions

int run()

The main function.


struct roq::Logger

Interface to manage the lifetime of the single static logger.

Public Static Functions

static void initialize(const std::string_view &arg0, const Config&, bool stacktrace = true)

Initialize the logger.

static void shutdown()

Shutdown the logger.

struct Config