MAUVE Runtime Logger

MAUVE Runtime provides a logging infrastructure settled on spdlog. In your source code, it allows to log message of several levels to categories. At configuration time, it allows to decide which category logs at which level, and how.

MAUVE Loggers

By default, MAUVE Runtime provides loggers (corresponding to categories) for:

  • the deployer (as runtime category)
  • each component of the architecture (component name is used as category)
  • each resource of the architecture (resource name is used as category)
  • custom categories

Log levels

Available log levels are: trace, debug, info, warn, error and critical.

Log formats

Formatting a message for logging is very simple and uses parameter substitution. All logging methods take as first argument a formatted string, and as following arguments the parameters to be substituted. See "http://fmtlib.net/latest/syntax.html" for the syntax description.

Logging from source code

From components and resources

Component and resource objects already have a logger configured. Hence, when you define your own shell/core/fsm/interface, you can use the logger to log message to the corresponding category. For instance, the following code defines a new core type C, and in its update method, the data read from read_port is logged to the component logger with level info. Each log level has its corresponding method.

struct C: public Core<S> {
  void update() {
    int i = shell().read_port.read();
    this->logger().info("read {}", i);
  }
};

The 'runtime' category

The runtime category is generally used to log specific MAUVE Runtime messages corresponding to configuration and starting of components, threads, ... It is not advised to use this logger from user code.

Logging to a custom category

If you want to create your own category, for instance to split log messages coming from you component into several categories, you can create and access a new one using the CategoryLogger class:

struct C: public Core<S> {
  void update() {
    int i = shell().read_port.read();
    CategoryLogger("my_category").info("read {}", i);
  }
};

Configuring the logging infrastructure

YAML configuration

Logging configuration follows the YAML format. If you used the mauve::runtime::main function in your deployment, then you can use the --logger option to configure the logger from a YAML file. An example of a YAML file is given below to illustrate the corresponding syntax:

default:
  level: debug
  type: stdout
cpt_1:
  - type: stdout
    level: info
cpt_2:
  - type: stdout
    level: info
  - type: rosjson
    level: info

This code configures:

  • the default logger (runtime plus all not configured categories):
    • its logging level is debug
    • the log messages go to stdout
  • the logger for component cpt_1:
    • its logging level is info
    • the log messages go to stdout
  • the logger for component cpt_2:
    • the log messages go to stdout with level info and to rosjson with level info

Logging sinks

MAUVE Runtime logging supports the following types (i.e. places where the log are sent/written):

  • stdout: logs are printed to the standard output
  • stderr: logs are printed to the error output
  • file: logs are printed to a file; the filename can be specified as a supplementary argument
  • daily_file: logs are printed to a new file each day; the filename, as well as the hour and minutes at which the new file must be created can be specified as a supplementary argument
  • rotating_file: logs are printed to new files when the max. file size is reached; the filename, as well as the max_size and max_files can be specified as a supplementary argument
  • rosjson: logs are sent in JSON format on a UDP port; this logging type is compliant with rosbridge and allows to display MAUVE logs in the ROS console; ip and port of the rosbridge server can be specified as a supplementary argument

Logging to ROS console

The rosjson logging type allows to send log messages to the rosbridge server using UDP. This server parses the JSON streams sent by MAUVE and produces ROS log messages to the /rosout topic. MAUVE log messages can then be displayed, for instance, in rqt_console. To use this logging, you can simply launch the rosbridge UDP server:

roslaunch rosbridge_server rosbridge_udp.launch

Then launch the console UI: rqt_console

MAUVE Runtime logs

MAUVE Runtime already uses logging to log important messages. Log messages provided by the MAUVE Runtime (with logging levels indicated within parentheses) are:

  • for each FSM:
    • (trace) the state name being run
    • (trace) the transition being tested
    • (trace) the state to which the FSM goes
  • for each WriteService/EventService/CallService/ReadService:
    • (trace) the service being called
  • in the runtime category:
    • (debug) logger creation and configuration
    • (warn) if the configured logger is unknown
    • (warn) deployment issues when trying to setup component clocks, or to get system clock
    • (error) deployment errors when trying to setup component clocks, or to get system clock
    • (info) start/stop of the deployment
    • (debug) creation/activation/start/stop/clearing of tasks
    • (info) architecture configuration/cleaning
    • (debug) creation/configuration/cleaning of Shells, Cores, FSMs, Interfaces
  • for each component:
    • (warn) RT configuration issues
    • (error) task creation errors

results matching ""

    No results matching ""