Logging Module

Module Contents

TRACKTABLE_LOG(lvl)

Logging: configurable log messages in C++.

Write log messages from C++ code using the following template:

TRACKTABLE_LOG(<level>) << “My log message!”;

where ‘level’ is one of ‘tracktable::log::trace’, ‘tracktable::log::debug’, ‘tracktable::log::info’, ‘tracktable::log::warning’, ‘tracktable::log::error’, or ‘tracktable::log::fatal’.

You may want to use ‘using namespace tracktable::log’ in order to import those symbols and save yourself from typing a lot of colons.

Right now there is only a single log sink: standard error. If you need to redirect messages to a file you can use Boost’s log module. Treat TRACKTABLE_LOG as if it were BOOST_LOG_TRIVIAL (in fact, it is!) and use Boost’s log sinks.

void TRACKTABLE_CORE_EXPORT tracktable::set_log_level(::tracktable::log::severity_level new_level)

Set minimum level at which log messages will be displayed.

By default, any message with a log level of ‘info’ or above. This may result in too much output for you. In that case, call this function to increase it. For example, if you only want warnings and errors:

tracktable::set_log_level(tracktable::log::warning);

The available log levels are as follows:

  • trace: Extremely verbose output about algorithm execution. You will only need this if you are debugging Tracktable’s internals.

  • debug: Moderately verbose output about algorithm execution. You will probably never need this, although it is sometimes useful when you need to track down a problem.

  • info: Routine, summary information about what’s going on, including start/end notifications for code that takes a long time to execute such as DBSCAN clustering. It is always safe to set the log level higher than ‘info’.

  • warning: Something has gone wrong but execution can continue. Results may be strange or unusable.

  • error: Something has gone wrong and execution probably will not continue.

  • fatal: Something has gone very wrong and execution cannot continue.

Arguments: new_level: Desired minimum log level. Must be of type tracktable::log::severity_level, an enum whose members are the six levels listed above.

Returns: No return value.

log::severity_level TRACKTABLE_CORE_EXPORT tracktable::log_level()

Get current log level.

Return the current log level. Log messages with a severity less than this level will not be displayed.

Note that this function will only return accurate results if you use tracktable::set_log_level() to set the log level. If you use Boost calls to go behind the library’s back, it will not be able to track what you do.

Arguments: No arguments.

Returns: Current log level (as tracktable::log::severity_level)