ywkaras commented on code in PR #10899:
URL: https://github.com/apache/trafficserver/pull/10899#discussion_r1420972888


##########
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:
   Are you using the Swift compiler again?
   ```
   wkaras ~/REPOS/TS
   O$ git status
   On branch cleanup-ts-bwf
   Changes not staged for commit:
     (use "git add <file>..." to update what will be committed)
     (use "git restore <file>..." to discard changes in working directory)
        modified:   src/tscore/Diags.cc
   
   no changes added to commit (use "git add" and/or "git commit -a")
   wkaras ~/REPOS/TS
   O$ git diff
   diff --git a/src/tscore/Diags.cc b/src/tscore/Diags.cc
   index 0092f9d9d..d1f870326 100644
   --- a/src/tscore/Diags.cc
   +++ b/src/tscore/Diags.cc
   @@ -214,6 +214,9 @@ Diags::~Diags()
      deactivate_all(DiagsTagType_Action);
    }
    
   +namespace
   +{
   +
    struct DiagTimestamp {
      std::chrono::time_point<std::chrono::system_clock> ts = 
std::chrono::system_clock::now();
    };
   @@ -245,6 +248,8 @@ bwformat(swoc::BufferWriter &w, swoc::bwf::Spec const 
&spec, DiagThreadname cons
      return w;
    }
    
   +} // end anonymous namespace
   +
    
//////////////////////////////////////////////////////////////////////////////
    //
    //      void Diags::print_va(...)
   wkaras ~/REPOS/TS
   O$ cmake --build build
   [0/2] Re-checking globbed directories...
   [54/54] Linking CXX executable 
plugins/experimental/uri_signing/unit_tests/uri_signing_test
   wkaras ~/REPOS/TS
   O$ 
   ```



-- 
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

Reply via email to