Using the Logger from Fair

For a complete documentation please refer to the FairLogger documentation.

Usage inside the Code

The basic syntax is

LOG(info) << "My information";

Severity keywords

With LOG(<keyword>) you can mark the messaged by severity. The higher severity levels also print the lower levels, e.g. info will print warn, too. Most people in Panda use info, warn and error.

"trace"
"debug4"
"debug3"
"debug2"
"debug1"
"debug"
"info"
"state"
"warn"
"error"
"fatal"
"nolog"

Options in a ROOT macro

To set the Logger options inside your Root macro follow this structure, which will give a lot of information

#include <fairlogger/Logger.h>
int myacro()
{
  fair::Logger::SetConsoleColor(true);
  fair::Logger::SetVerbosity("veryhigh");
  ...
}

Coloured console output

Adds a nice and easy way to spot errors by the colored keywords. fair::Logger::SetConsoleColor(true); Be aware that this should be off when logging to a file, because the coloring is performed by escape sequences which will clog your logs.

Logger Verbosity

Here you can adjust what the logger puts in front of the actual message. There are custom verbosity levels as well, if needed.:

verylow:  message
low:      [severity] message
medium:   [HH:MM:SS][severity] message
high:     [process_name][HH:MM:SS][severity] message
veryhigh: [process_name][HH:MM:SS:µS][severity][file:line:function] message
user1:    [severity] message
user2:    [severity] message
user3:    [severity] message
user4:    [severity] message

When running a root macro e.g. for simulations, the process will always be root.exe and the time stamps are only in a few cases of use. This example may be most practical for debugging and results in [severity][file:line:function] message

auto spec = fair::VerbositySpec::Make(fair::VerbositySpec::Info::severity,
                                      fair::VerbositySpec::Info::file_line_function);
fair::Logger::DefineVerbosity("user1", spec);
fair::Logger::SetVerbosity("user1");

Here is the list of available:

+-----------------------------------------------+----------------------+
| Argument                                      | Result               |
+===============================================|======================|
| fair::VerbositySpec::Info::process_name       | [process_name]       |
| fair::VerbositySpec::Info::timestamp_s        | [HH:MM:SS]           |
| fair::VerbositySpec::Info::timestamp_us       | [HH:MM:SS:µS]        |
| fair::VerbositySpec::Info::severity           | [severity]           |
| fair::VerbositySpec::Info::file               | [file]               |
| fair::VerbositySpec::Info::file_line          | [file:line]          |
| fair::VerbositySpec::Info::file_line_function | [file:line:function] |
+-----------------------------------------------+----------------------+