-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathBotAssert.cpp
41 lines (34 loc) · 1.18 KB
/
BotAssert.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "BotAssert.h"
#include <iostream>
namespace Assert
{
std::string lastErrorMessage;
const std::string CurrentDateTime()
{
auto t = std::time(nullptr);
auto tm = *std::localtime(&t);
std::stringstream ss;
ss << std::put_time(&tm, "%d-%m-%Y %H-%M-%S");
return ss.str();
}
void ReportFailure(const char * condition, const char * file, int line, const char * msg, ...)
{
char messageBuffer[1024] = "";
if (msg != nullptr)
{
va_list args;
va_start(args, msg);
vsnprintf(messageBuffer, 1024, msg, args);
va_end(args);
}
std::stringstream ss;
ss << std::endl;
ss << "!Assert: " << condition << std::endl;
ss << "File: " << file << std::endl;
ss << "Message: " << messageBuffer << std::endl;
ss << "Line: " << line << std::endl;
ss << "Time: " << CurrentDateTime() << std::endl;
lastErrorMessage = messageBuffer;
std::cerr << ss.str();
}
}