[Lldb-commits] [lldb] [lldb-dap] Improving logging support and formatting. (PR #170731)
Sergei Druzhkov via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 4 13:34:14 PST 2025
================
@@ -46,14 +41,32 @@ namespace lldb_dap {
/// `DAP_LOG_ERROR` helpers.
class Log final {
public:
- /// Creates a log file with the given filename.
- Log(llvm::StringRef filename, std::error_code &EC);
+ using Mutex = std::recursive_mutex;
- void WriteMessage(llvm::StringRef message);
+ Log(llvm::raw_ostream &stream, Mutex &mutex)
+ : m_stream(stream), m_mutex(mutex) {}
+ Log(llvm::StringRef prefix, const Log &log)
+ : m_prefix(prefix), m_stream(log.m_stream), m_mutex(log.m_mutex) {}
+
+ /// Retuns a new Log instance with the associated prefix for all messages.
+ inline Log WithPrefix(llvm::StringRef prefix) const {
+ std::string full_prefix =
+ m_prefix.empty() ? prefix.str() : m_prefix + " " + prefix.str();
----------------
DrSergei wrote:
I am not sure that it is correct logic. For example, I create logger with prefix `a`. After that I add prefix `b`, so full prefix will be `a b `. After that, I add prefix `c`, that leads to `a b c ` with double space.
https://github.com/llvm/llvm-project/pull/170731
More information about the lldb-commits
mailing list