forked from thiagowinkler/pairs-trading-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.cpp
40 lines (31 loc) · 746 Bytes
/
Logger.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 "Logger.h"
Logger* Logger::instance = nullptr; // initialization of the static pointer
// Getter of the instance of the class
Logger* Logger::get_instance()
{
if (!instance) // only one instance of the class can be created
{
instance = new Logger();
}
return instance;
}
// Open a new log file
bool Logger::open_log_file(std::string file_path)
{
this->log.open(file_path);
return this->log.is_open();
}
// Write a line to the log file
void Logger::write_log_line(std::string line, bool verbose)
{
this->log << line << std::endl;
// If verbose, also print line on console
if(verbose)
std::cout << line << std::endl;
}
// Close the current log file
bool Logger::close_log_file()
{
this->log.close();
return true;
}