[Lldb-commits] [lldb] [lldb-dap] show a useful timestamp in log messages (PR #170737)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 5 03:24:27 PST 2025
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/170737
>From facbbb7f129011d91f70404ce225e38d7fe0aeea Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Thu, 4 Dec 2025 20:25:54 +0000
Subject: [PATCH 1/2] [lldb-dap] show a useful timestamp in log message
---
lldb/tools/lldb-dap/DAPLog.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lldb/tools/lldb-dap/DAPLog.cpp b/lldb/tools/lldb-dap/DAPLog.cpp
index f66784e197518..5b1d650a87241 100644
--- a/lldb/tools/lldb-dap/DAPLog.cpp
+++ b/lldb/tools/lldb-dap/DAPLog.cpp
@@ -8,6 +8,7 @@
#include "DAPLog.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
#include "llvm/Support/raw_ostream.h"
#include <chrono>
#include <mutex>
@@ -20,10 +21,9 @@ namespace lldb_dap {
Log::Log(StringRef filename, std::error_code &EC) : m_stream(filename, EC) {}
void Log::WriteMessage(StringRef message) {
- std::lock_guard<std::mutex> lock(m_mutex);
- std::chrono::duration<double> now{
- std::chrono::system_clock::now().time_since_epoch()};
- m_stream << formatv("{0:f9} ", now.count()).str() << message << "\n";
+ const std::lock_guard<std::mutex> lock(m_mutex);
+ const llvm::sys::TimePoint<> time = std::chrono::system_clock::now();
+ m_stream << formatv("[{0:%H:%M:%S.%L}] ", time) << message << '\n';
m_stream.flush();
}
>From 66ad92d197e81f713b1a306d8160ae04ee7018e9 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Fri, 5 Dec 2025 11:24:00 +0000
Subject: [PATCH 2/2] [lldb] add review changes
---
lldb/tools/lldb-dap/DAPLog.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/tools/lldb-dap/DAPLog.cpp b/lldb/tools/lldb-dap/DAPLog.cpp
index 5b1d650a87241..34d26128efd3f 100644
--- a/lldb/tools/lldb-dap/DAPLog.cpp
+++ b/lldb/tools/lldb-dap/DAPLog.cpp
@@ -21,7 +21,7 @@ namespace lldb_dap {
Log::Log(StringRef filename, std::error_code &EC) : m_stream(filename, EC) {}
void Log::WriteMessage(StringRef message) {
- const std::lock_guard<std::mutex> lock(m_mutex);
+ std::lock_guard<std::mutex> lock(m_mutex);
const llvm::sys::TimePoint<> time = std::chrono::system_clock::now();
m_stream << formatv("[{0:%H:%M:%S.%L}] ", time) << message << '\n';
m_stream.flush();
More information about the lldb-commits
mailing list