| 142 | } |
| 143 | |
| 144 | std::string IsoTimestamp() { |
| 145 | auto now = std::chrono::system_clock::now(); |
| 146 | auto tt = std::chrono::system_clock::to_time_t(now); |
| 147 | auto ms = std::chrono::duration_cast<std::chrono::milliseconds>( |
| 148 | now.time_since_epoch()) % 1000; |
| 149 | struct tm tm_buf; |
| 150 | localtime_r(&tt, &tm_buf); |
| 151 | char buf[32]; |
| 152 | std::snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d.%03d", |
| 153 | tm_buf.tm_year + 1900, tm_buf.tm_mon + 1, tm_buf.tm_mday, |
| 154 | tm_buf.tm_hour, tm_buf.tm_min, tm_buf.tm_sec, |
| 155 | static_cast<int>(ms.count())); |
| 156 | return buf; |
| 157 | } |
| 158 | |
| 159 | // Walk an SSE buffer and concatenate every choices[].delta.content piece. |
| 160 | // Used by the jsonl logger so the human-readable response field carries |