-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlog.cpp
More file actions
40 lines (32 loc) · 700 Bytes
/
log.cpp
File metadata and controls
40 lines (32 loc) · 700 Bytes
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 "log.h"
#include <stdarg.h>
#include <iostream>
#include <fstream>
#include <windows.h>
Log::ELogLevel Log::log_level;
void Log::set_level(ELogLevel level)
{
log_level = level;
}
void Log::message(ELogLevel level, std::string fmt, ...)
{
if (level < log_level)
return;
char text[MESSAGE_MAX_LEN];
va_list ap;
if (fmt.length() != 0)
{
va_start(ap, fmt);
_vsnprintf(text, MESSAGE_MAX_LEN, fmt.c_str(), ap);
va_end(ap);
std::cout << text;
std::ofstream f;
f.open("log.txt", std::ios_base::app);
f << text;
f.close();
}
}
/*void Log::message(std::string msg)
{
std::cout << msg;
}*/