Program Listing for File logging.h

Return to documentation for file (include/amici/logging.h)

#ifndef AMICI_LOGGER_H
#define AMICI_LOGGER_H

#include <string>
#include <vector>

namespace amici {

struct LogItem;

enum class LogSeverity {
    error,
    warning,
    debug,
};

class Logger {
  public:
    Logger() = default;
    void
    log(LogSeverity severity, std::string const& identifier,
        std::string const& message);

#if SWIG_VERSION >= 0x040002
#else
    // swig 4.0.1 segfaults on "@param ..."
    // see https://github.com/swig/swig/issues/1643
#endif
    void
    log(LogSeverity severity, std::string const& identifier, char const* format,
        ...);

    std::vector<LogItem> items;
};

struct LogItem {
    LogItem() = default;

    LogItem(
        LogSeverity severity, std::string const& identifier,
        std::string const& message
    )
        : severity(severity)
        , identifier(identifier)
        , message(message){};

    LogSeverity severity = LogSeverity::error;

    std::string identifier;

    std::string message;
};

} // namespace amici
#endif // AMICI_LOGGER_H