cmcfarlen commented on code in PR #10899: URL: https://github.com/apache/trafficserver/pull/10899#discussion_r1422780176
########## src/tscore/Diags.cc: ########## @@ -213,6 +214,37 @@ Diags::~Diags() deactivate_all(DiagsTagType_Action); } +struct DiagTimestamp { + std::chrono::time_point<std::chrono::system_clock> ts = std::chrono::system_clock::now(); +}; + +swoc::BufferWriter & +bwformat(swoc::BufferWriter &w, swoc::bwf::Spec const &spec, DiagTimestamp const &ts) +{ + auto epoch = std::chrono::system_clock::to_time_t(ts.ts); + swoc::LocalBufferWriter<48> lw; + + ctime_r(&epoch, lw.aux_data()); + lw.commit(19); // keep only leading text. + lw.print(".{:03}", std::chrono::time_point_cast<std::chrono::milliseconds>(ts.ts).time_since_epoch().count() % 1000); + w.write(lw.view().substr(4)); + + return w; +} + +struct DiagThreadname { + char name[32]; + + DiagThreadname() { ink_get_thread_name(name, sizeof(name)); } +}; + +swoc::BufferWriter & +bwformat(swoc::BufferWriter &w, swoc::bwf::Spec const &spec, DiagThreadname const &n) +{ + bwformat(w, spec, std::string_view{n.name}); + return w; +} + Review Comment: It does work, but it confuses clang-tidy. Thanks -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org