Logging capacitiesΒΆ

class chemfiles::Logger

The Logger class is a singleton class providing logging facilities.

Public Type

LogBackend enum

Where the log message should go.

Values:

  • SILENT -

    Do not log anything.

  • STDOUT -

    Log to stdout.

  • STDERR -

    Log to stderr.

  • FILE -

    Log to a file.

  • CALLBACK -

    Log to the C callback.

Public Static Functions

template <typename... Args>
void log(LogLevel level, Args const &... args)

Log a message if the level is lower than the maximal curent logging level. The message can be built using a variadic function call, like: ```cxx Logger::log(LogLevel::ERROR, “Here ”, ” and ”, 4, ” times ”, there->call()); ```

template <typename... Args>
void error(Args const &... args)

Equivalent to Logger::log(LogLevel::ERROR, args...)

template <typename... Args>
void warn(Args const &... args)

Equivalent to Logger::log(LogLevel::ERROR, args...)

template <typename... Args>
void info(Args const &... args)

Equivalent to Logger::log(LogLevel::ERROR, args...)

template <typename... Args>
void debug(Args const &... args)

Equivalent to Logger::log(LogLevel::ERROR, args...)

void set_level(LogLevel level)

Set the logging level.

LogLevel level()

Get the current logging level.

void to_stdout()

Make the logger output to stdout.

void to_stderr()

Make the logger output to stderr.

void silent()

Silent the logger.

void to_file(const std::string & path)

Make the logger output to the file at path. The file will be created and overwrited if it already exists.

void callback(logging_cb_t function)

Set a callback that will be called to perform logging.

LogBackend backend()

Get the current logging backend.