Logging

Overview

Aether Engine provides an API which can be used to log messages from simulation execution. Applications using the logging API need to include the aether/common/logging.hh header.

Windows Support

At present the logging API is not functional under Windows and should only be included and used inside simulation code.

In addition any Windows code should define the C preprocessor macro WITHOUT_HADEAN_LOGGING before including Aether headers since uses of the logging API may be pulled in transitively.

Initialisation

Executables using the logging API must initialise it before any messages can be logged. This can be done with a call to aether::log::init():

aether::log::init(process_name, process_pid);

process_name should be a short string to help identify the process. process_pid is a value of type uint64_t which is expected to be a process identifier. Hadean PIDs can be cast to uint64_ts to supply this value. Neither process_name nor process_pid are required to be meaningful.

We advise calling this function just after hadean::init().

Setting a Logging Level

The logging level can be set via a call to aether::log::set_level() as follows;

aether::log::set_level(aether::log::level::INFO);

Only messages equal to or above the specified level will be logged. The following levels are defined in the scope of aether::log::level: TRACE, DEBUG, INFO, WARN, ERROR and FATAL.

In the provided demos Aether Engine sets the logging level for all processes in the simulation to the one specified in the aether::arguments instance used to construct the octree.

Logging messages

There are two ways to log messages. The first is capable of printing any C++ type that provides a C++ streaming output operator:

const int n = 42;
const std::string s = "Hello world!";
AETHER_LOG(INFO)("The value of n is ", n, " and the value of s is ", s);

The second allows the use of printf-style format strings:

const int n = 42;
const std::string s = "Hello world!";
AETHER_LOG(INFO).printf("The value of n is %i and the value of s is %s", n, s.c_str());