Files
Nuake-custom/Nuake/src/Core/Logger.cpp
Antoine Pilote 0c6ed48bbd Major cleanup.
Moved to namespace
Cleanup includes
2021-07-11 18:56:44 -04:00

37 lines
669 B
C++

#include "Logger.h"
#include <iostream>
#include <chrono>
#include <string>
#include <time.h>
namespace Nuake
{
std::vector<LogEntry> Logger::m_Logs = std::vector<LogEntry>();
void Logger::Log(std::string log, LOG_TYPE type)
{
char buff[100];
time_t now = time(0);
strftime(buff, 100, "%Y-%m-%d %H:%M:%S.000", localtime(&now));
LogEntry newLog = {
type,
buff,
log
};
std::string msg = "[" + std::string(buff) + "]" + std::string(" - ") + log;
printf((msg + "\n").c_str());
if (m_Logs.size() >= MAX_LOG)
m_Logs.erase(m_Logs.begin());
m_Logs.push_back(newLog);
}
std::vector<LogEntry> Logger::GetLogs()
{
return m_Logs;
}
}