Constructs a string that contains current date & time in the format: "YYYYMMDD-HHMMSS"
| 467 | |
| 468 | // Constructs a string that contains current date & time in the format: "YYYYMMDD-HHMMSS" |
| 469 | static std::string ConstructDateTimeString() |
| 470 | { |
| 471 | time_t current_time = time(0); |
| 472 | std::stringstream s; |
| 473 | bool success = false; |
| 474 | #ifdef _WIN32 |
| 475 | struct tm tt; |
| 476 | struct tm* pT = &tt; |
| 477 | success = (localtime_s(&tt, ¤t_time) == 0); |
| 478 | #else |
| 479 | struct tm* pT = localtime(¤t_time); |
| 480 | success = (pT != nullptr); |
| 481 | #endif |
| 482 | if (success) |
| 483 | { |
| 484 | s << std::to_string(pT->tm_year + 1900) << std::to_string(pT->tm_mon + 1) << std::to_string(pT->tm_mday) << |
| 485 | "-" << std::to_string(pT->tm_hour) << std::to_string(pT->tm_min) << std::to_string(pT->tm_sec); |
| 486 | } |
| 487 | return s.str(); |
| 488 | } |
| 489 | |
| 490 | // Checks if a message should be processed based on provided message level and current log file level. |
| 491 | template<LogDst DST> |