#include "logWrapper.h"

#include "log.h"

namespace
{
//--------------------------------------------------------------
void postMessage(dBus::Bus &bus, const api::log::LogLevel logLevel, const std::string &message)
{
  api::log::LogMessage logMsg;
  logMsg.level   = logLevel;
  logMsg.message = message;

  // Post the log message to the bus with the appropriate category (Fire-and-forget, no response expected)
  (void)dBus::api::postData(bus, logMsg.getID(), logMsg, dBus::MessageCategory::Log);
}
//--------------------------------------------------------------
}     // namespace

//--------------------------------------------------------------
void api::log::postLogMessage(dBus::Bus &bus, const std::string &message)
{
  postMessage(bus, LogLevel::Message, message);
}
//--------------------------------------------------------------
void api::log::postLogDebug(dBus::Bus &bus, const std::string &message)
{
  postMessage(bus, LogLevel::Debug, message);
}
//--------------------------------------------------------------
void api::log::postLogInfo(dBus::Bus &bus, const std::string &message)
{
  postMessage(bus, LogLevel::Info, message);
}
//--------------------------------------------------------------
void api::log::postLogWarning(dBus::Bus &bus, const std::string &message)
{
  postMessage(bus, LogLevel::Warning, message);
}
//--------------------------------------------------------------
void api::log::postLogError(dBus::Bus &bus, const std::string &message)
{
  postMessage(bus, LogLevel::Error, message);
}
//--------------------------------------------------------------
void api::log::postLogSystem(dBus::Bus &bus, const std::string &message)
{
  postMessage(bus, LogLevel::System, message);
}
//--------------------------------------------------------------
