You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "cmcfarlen (via GitHub)" <gi...@apache.org> on 2023/12/06 19:38:50 UTC
[PR] remove ts_bwf.cc and update locations where its used [trafficserver]
cmcfarlen opened a new pull request, #10899:
URL: https://github.com/apache/trafficserver/pull/10899
This remove tscpp/util/ts_bwf.cc and moves the used functionality to Diags.cc
The way that ts_bwf.cc registers globals does not play well with static libraries and was causing problems removing a circular dependency. Also, this functionality (afaict) is only used in tscore/Diags.cc, so rather than carry this complexity for small benefit, I have factored this file out.
--
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-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] remove ts_bwf.cc and update locations where its used [trafficserver]
Posted by "ywkaras (via GitHub)" <gi...@apache.org>.
ywkaras commented on code in PR #10899:
URL: https://github.com/apache/trafficserver/pull/10899#discussion_r1418160433
##########
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:
Should all these added definitions be in an anonymous namespace?
--
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-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] remove ts_bwf.cc and update locations where its used [trafficserver]
Posted by "ywkaras (via GitHub)" <gi...@apache.org>.
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-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] remove ts_bwf.cc and update locations where its used [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
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-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] remove ts_bwf.cc and update locations where its used [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen merged PR #10899:
URL: https://github.com/apache/trafficserver/pull/10899
--
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-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] remove ts_bwf.cc and update locations where its used [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #10899:
URL: https://github.com/apache/trafficserver/pull/10899#discussion_r1420812868
##########
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:
adding to an anonymous namespace hides them from consideration as an overload.
--
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-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org