2
/// Implements the logging file writer.
8
std::ofstream Logger::m_file;
10
bool Logger::Open(std::string filename)
14
m_file.open(filename.c_str(), std::ios::out | std::ios::app);
15
WriteLine("Logging started");
16
return m_file.is_open();
21
WriteLine("Logging ended");
26
void Logger::WriteLine(std::string line)
29
m_file << GetDateTime() << " :: " << line << std::endl;
32
std::string Logger::GetDateTime()
34
std::stringstream stream;
36
tm *ltm = localtime(&now);
37
stream << 1900 + ltm->tm_year << "-";
39
stream << "0" << ltm->tm_mon + 1 << "-";
41
stream << ltm->tm_mon + 1 << "-";
42
if (ltm->tm_mday < 10)
43
stream << "0" << ltm->tm_mday << " ";
45
stream << ltm->tm_mday << " ";
46
if (ltm->tm_hour < 10)
47
stream << "0" << ltm->tm_hour << ":";
49
stream << ltm->tm_hour << ":";
51
stream << "0" << ltm->tm_min << ":";
53
stream << ltm->tm_min << ":";
55
stream << "0" << ltm->tm_sec;
57
stream << ltm->tm_sec;