MOTIS utl module documentation
MOTIS is an open-source software platform for efficient planning and routing in multi-modal transportation systems. GitHub main repository: https://github.com/motis-project/motis
This is the documentation for the utl (utility) module.
Logging
The simplest way to produce log lines is to use the utl:log()
function,
or the wrapping functions for the various log levels,
utl::log_debug()
, utl::log_info()
and utl::log_error()
:
#include "utl/logging.h"
utl::log_info("MyCtx", "Simple message");
The first parameter is the context, that provides an information of the origin of the log line inside MOTIS code.
The following log levels are supported:
- debug
Messages that contain information only useful when debugging MOTIS
- info
Important information about a normal behavior of the program
- error
Details on an abnormal behavior of the application
Advanced usage
You can insert variables in the message by using {}
and passing them as extra arguments
(formatting is performed by the fmt library):
utl::log_info("MyCtx", "String={} Int={}", "Hello", 42);
You can specify metadata using .attrs()
:
utl::log_info("MyCtx", "Message").attrs({{"key1", "value1"}, {"key2", "value2"}});
API details
-
template<typename ...Args>
struct log_debug : public utl::log<log_level::debug, Args...> Produce a new DEBUG log line.
-
template<typename ...Args>
struct log_info : public utl::log<log_level::info, Args...> Produce a new INFO log line.
-
template<typename ...Args>
struct log_error : public utl::log<log_level::error, Args...> Produce a new ERROR log line.
Note
Those logging function are an exception to the rule that, in MOTIS,
we use Aggregate Initialization wherever possible,
but here we do not want to use utl::log_info{...}
.