7 bool Logger::setLogFile(const std::string & fileName)
9 fout.open(fileName.c_str(), std::ios::app);
11 return !(consoleLog = !fout.is_open());
14 std::ostream & Logger::operator<<(const std::string & str)
18 return std::cout << str;
21 fout.open(logFile.c_str(), std::ios::app);
30 void Logger::_logDate()
32 time_t t = time(NULL);
33 struct tm *ts = localtime(&t);
36 << (ts->tm_year + 1900) << "-"
37 << (ts->tm_mon < 9 ? "0" : "") << (ts->tm_mon + 1) << "-"
38 << (ts->tm_mday < 10 ? "0" : "") << ts->tm_mday << " "
39 << (ts->tm_hour < 10 ? "0" : "") << ts->tm_hour << ":"
40 << (ts->tm_min < 10 ? "0" : "") << ts->tm_min << ":"
41 << (ts->tm_sec < 10 ? "0" : "") << ts->tm_sec
45 fout.open(logFile.c_str(), std::ios::app);
48 << (ts->tm_year + 1900) << "-"
49 << (ts->tm_mon < 9 ? "0" : "") << (ts->tm_mon + 1) << "-"
50 << (ts->tm_mday < 10 ? "0" : "") << ts->tm_mday << " "
51 << (ts->tm_hour < 10 ? "0" : "") << ts->tm_hour << ":"
52 << (ts->tm_min < 10 ? "0" : "") << ts->tm_min << ":"
53 << (ts->tm_sec < 10 ? "0" : "") << ts->tm_sec