#include "journallogger.h"
#include <systemd/sd-journal.h>

namespace myapp::logging {

static void report(int level, std::string const& tag, std::string const& message) noexcept
{
    sd_journal_print(level, "%s: %s", tag.c_str(), message.c_str());
}

void journal_logger::debug(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_DEBUG, tag, message);
}

void journal_logger::info(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_INFO, tag, message);
}

void journal_logger::notice(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_NOTICE, tag, message);
}

void journal_logger::warning(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_WARNING, tag, message);
}

void journal_logger::error(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_ERR, tag, message);
}

void journal_logger::critical(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_CRIT, tag, message);
}

void journal_logger::alert(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_ALERT, tag, message);
}

void journal_logger::emergency(std::string const& tag, std::string const& message) noexcept
{
    report(LOG_EMERG, tag, message);
}

} /* namespace myapp::logging */
