Skip to content

Commit 2cfea14

Browse files
authored
[lldb-dap] Add timestamps to protocol logs (#93540)
I've found them very useful as a rudimentary form of benchmark.
1 parent 53d79fe commit 2cfea14

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ void DAP::SendJSON(const llvm::json::Value &json) {
103103
SendJSON(json_str);
104104

105105
if (log) {
106-
*log << "<-- " << std::endl
106+
auto now = std::chrono::duration<double>(
107+
std::chrono::system_clock::now().time_since_epoch());
108+
*log << llvm::formatv("{0:f9} <-- ", now.count()).str() << std::endl
107109
<< "Content-Length: " << json_str.size() << "\r\n\r\n"
108110
<< llvm::formatv("{0:2}", json).str() << std::endl;
109111
}
@@ -130,9 +132,12 @@ std::string DAP::ReadJSON() {
130132
if (!input.read_full(log.get(), length, json_str))
131133
return json_str;
132134

133-
if (log)
134-
*log << "--> " << std::endl << "Content-Length: " << length << "\r\n\r\n";
135-
135+
if (log) {
136+
auto now = std::chrono::duration<double>(
137+
std::chrono::system_clock::now().time_since_epoch());
138+
*log << llvm::formatv("{0:f9} --> ", now.count()).str() << std::endl
139+
<< "Content-Length: " << length << "\r\n\r\n";
140+
}
136141
return json_str;
137142
}
138143

0 commit comments

Comments
 (0)