Skip to content

Message logging

Mario Bielert edited this page Mar 19, 2018 · 9 revisions

The wrapper provides an easily usable logging interface. The interface can log string messages with a given severity. Log output can be filtered by severity.

List of severity levels

There are six different severity levels; In descending order, these are:

  • FATAL
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE

Filter by severity

Any logged messages will be filtered by their severity. The level of severity needed to show a message is read from the Environment using the expanded variable VERBOSE. If this variable is not set, the required severity is set to WARN. If the variable is set, its content is read for a valid severity level. If that fails, the required severity is set to INFO.

Compile time filtering

The used logging infrastructure can also filter messages at compile time. The minimum required severity can be adjusted with the CMake variable MIN_LOG_LEVEL. By default this is dependant on the used build type. For DEBUG, trace is used, otherwise debug is used. If your not using CMake, you have to define NITRO_LOG_MIN_SEVERITY. Possible values are:

  • fatal
  • error
  • warn
  • info
  • debug
  • trace

Note:

As this is a compile time filtering, the verbosity cannot be raised to something more than the value used for compile time filtering at runtime.

Create a logging output

In order to have the needed definitions, you need to include the header scorep/plugin/log.hpp. That declares the class scorep::plugin::log::logging. This class has a static function for each severity level, which can be used to log a message like that.

scorep::plugin::log::logging::debug() << "This is just babble for debugging.";
scorep::plugin::log::logging::info() << "This is more a notice than an error.";
scorep::plugin::log::logging::fatal() << "Some fatal error happened.";

Of course, it may be useful to create an alias for that long name.

using scorep::plugin::log::logging;
logging::info() << "This is way shorter.";

See also

Clone this wiki locally