| 38 | namespace { |
| 39 | |
| 40 | std::string get_time(bool with_milliseconds = false) { |
| 41 | std::ostringstream oss; |
| 42 | time_t now = time(nullptr); |
| 43 | oss << std::put_time(localtime(&now), "%F %T"); |
| 44 | |
| 45 | if (with_milliseconds) { |
| 46 | auto now_chrono = std::chrono::system_clock::now(); |
| 47 | auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now_chrono.time_since_epoch()) % 1000; |
| 48 | oss << '.' << std::setfill('0') << std::setw(3) << milliseconds.count(); |
| 49 | } |
| 50 | |
| 51 | return oss.str(); |
| 52 | } |
| 53 | |
| 54 | template <typename T> |
| 55 | struct severity_strings { |
no test coverage detected