-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.cpp
More file actions
41 lines (33 loc) · 703 Bytes
/
logger.cpp
File metadata and controls
41 lines (33 loc) · 703 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
41
#include"logger.h"
#include"utils.h"
using namespace std;
//#define LOG_TO_CONSOLE
Logger::Logger(){
}
Logger::~Logger(){
fout_.close();
}
void Logger::Init(const char* logfile){
fout_.open(logfile, ios::out);
assert(fout_.is_open());
}
void Logger::LogToFile(char* msg){
char timestr[30];
GetTime(timestr);
fout_ << timestr;
fout_ << msg << endl << endl;
#ifdef LOG_TO_CONSOLE
cout << timestr;
cout << msg << endl << endl;
#endif
}
void Logger::LogToFile(const char* msg){
char timestr[30];
GetTime(timestr);
fout_ << timestr;
fout_ << msg << endl << endl;
#ifdef LOG_TO_CONSOLE
cout << timestr;
cout << msg << endl << endl;
#endif
}