|
|
|
@ -11,8 +11,10 @@
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <time.h>
|
|
|
|
#include <ctime>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Lunarium
|
|
|
|
namespace Lunarium
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -191,17 +193,17 @@ namespace Lunarium
|
|
|
|
{
|
|
|
|
{
|
|
|
|
time_t t = time(0);
|
|
|
|
time_t t = time(0);
|
|
|
|
|
|
|
|
|
|
|
|
struct tm now;
|
|
|
|
struct tm* now;
|
|
|
|
localtime_s(&now, &t);
|
|
|
|
now = localtime(&t);
|
|
|
|
|
|
|
|
|
|
|
|
std::ostringstream oss("");
|
|
|
|
std::ostringstream oss("");
|
|
|
|
oss << "[" << (now.tm_year + 1900) << "/";
|
|
|
|
oss << "[" << (now->tm_year + 1900) << "/";
|
|
|
|
oss << std::setfill('0') << std::setw(2);
|
|
|
|
oss << std::setfill('0') << std::setw(2);
|
|
|
|
oss << (now.tm_mon + 1) << "/"
|
|
|
|
oss << (now->tm_mon + 1) << "/"
|
|
|
|
<< std::setw(2) << now.tm_mday << " -- "
|
|
|
|
<< std::setw(2) << now->tm_mday << " -- "
|
|
|
|
<< std::setw(2) << now.tm_hour << ":"
|
|
|
|
<< std::setw(2) << now->tm_hour << ":"
|
|
|
|
<< std::setw(2) << now.tm_min << ":"
|
|
|
|
<< std::setw(2) << now->tm_min << ":"
|
|
|
|
<< std::setw(2) << now.tm_sec << "] ";
|
|
|
|
<< std::setw(2) << now->tm_sec << "] ";
|
|
|
|
return oss.str();
|
|
|
|
return oss.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -331,12 +333,15 @@ namespace Lunarium
|
|
|
|
void Logger::Log(uint32_t logCategory, uint32_t logLevel, const char * message, ...)
|
|
|
|
void Logger::Log(uint32_t logCategory, uint32_t logLevel, const char * message, ...)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// clear the buffer
|
|
|
|
// clear the buffer
|
|
|
|
memset(mBuffer, 0, 1024);
|
|
|
|
memset(mBuffer, 0, BUFFER_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strlen(message) >= BUFFER_SIZE)
|
|
|
|
|
|
|
|
throw std::runtime_error("Log message size exceeds buffer size");
|
|
|
|
|
|
|
|
|
|
|
|
// Fill the buffer with the formatted message
|
|
|
|
// Fill the buffer with the formatted message
|
|
|
|
va_list args;
|
|
|
|
va_list args;
|
|
|
|
va_start(args, message);
|
|
|
|
va_start(args, message);
|
|
|
|
vsprintf_s(mBuffer, BUFFER_SIZE, message, args);
|
|
|
|
vsprintf(mBuffer, message, args);
|
|
|
|
va_end(args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
|
|
double timeStamp = mTimer.GetElapsedSeconds();
|
|
|
|
double timeStamp = mTimer.GetElapsedSeconds();
|
|
|
|
|