Logging System

RAMICES III uses a custom-built logging system for printing output to the terminal. The LOG command is designed simply to replace the usual std::cout, with the following additional features:

  • Certain Logs can be suppressed at runtime, allowing for a more or less verbose output

  • Logs automatically format themselves with log-highlighting and (optionally) header banners

  • Log-lines can be erased with a simple command

  • Highlighting and erasing options are disabled if the

The LOG Command

LOG(level)

The main log interface. Pipe output to it as you would std::cout.

LOG is a specialised macro-interface to the LoggerCore object. If the level check evaluates to false, then the <<’d inputs are completely ignored and are not executed, useful for skipping expensive operations during a DEBUG run. Defined in @fileinfo{path}

Parameters:
  • level – A LogLevel object, if greater than the LogConfig::Level value, nothing happens (and the expansion is ignored)

Returns:

If the level is suitable, a temporary LoggerCore object, which functions as a specialised Stream object, accepting values passed via ‘<<’. Otherwise, does nothing, and does not evaluate any subsequent pipe commands

Detailed Documentation

Basic Usage

//test.cpp

#include "Log.h"
void testPrint(LogLevel level)
{
    LogConfig.SetLevel(level)
    LOG(DEBUG) << "This is detailed debugging"
    LOG(INFO) << "This is progress information";
    LOG(WARN) << "This is a warning that something went wrong\nBut was recovered.";
    LOG(ERROR) << "Something has gone very badly wrong";
}

int main(int argc, char**argv)
{
    testPrint(DEBUG);
    testPrint(WARN);
}

[DEBUG] This is detailed debugging
[INFO]  This is progress information
[WARN]  Line 7 of src/main.cpp in function testPrint
        This is a warning that something went wrong
        But was recovered.
[ERROR] Line 8 of src/main.cpp in function testPrint
        Something has gone very badly wrong
[WARN]  Line 7 of src/main.cpp in function testPrint
        This is a warning that something went wrong
        But was recovered.
[ERROR] Line 8 of src/main.cpp in function testPrint
        Something has gone very badly wrong