I want [2016-10-13 00:01:23.528514] */
| 47 | |
| 48 | /* I want [2016-10-13 00:01:23.528514] */ |
| 49 | void format_timestamp(std::ostream& os, uint64_t timestamp) |
| 50 | { |
| 51 | // The next 3 lines do not work on MSVC! |
| 52 | // auto duration = std::chrono::microseconds(timestamp); |
| 53 | // std::chrono::high_resolution_clock::time_point time_point(duration); |
| 54 | // std::time_t time_t = |
| 55 | // std::chrono::high_resolution_clock::to_time_t(time_point); |
| 56 | std::time_t time_t = timestamp / 1000000; |
| 57 | auto gmtime = std::gmtime(&time_t); |
| 58 | char buffer[32]; |
| 59 | strftime(buffer, 32, "%Y-%m-%d %T.", gmtime); |
| 60 | char microseconds[7]; |
| 61 | snprintf(microseconds, 7, "%06llu", |
| 62 | (long long unsigned int)timestamp % 1000000); |
| 63 | os << '[' << buffer << microseconds << ']'; |
| 64 | } |
| 65 | |
| 66 | std::thread::id this_thread_id() |
| 67 | { |