#include "consolelogger.h"
#include "utils/datetime.h"
#include <iostream>
#include <systemd/sd-daemon.h>

namespace myapp::logging {

static void report(const char* level, std::string const& tag, std::string const& message) noexcept
{
    try 
    {
        std::cerr << level << tag << ": " << message << std::endl;
    }
    catch (...)
    {
        
    }
}

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

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

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

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

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

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

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

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


} /* namespace myapp::logging */
