From d6312c338ba71ef0813ac51fdd7e05758e9fabe4 Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Fri, 19 Jan 2018 20:27:21 +0100 Subject: [PATCH] Logging: Improve text layout when discarding log timestamps When timestamps are removed from logging, the current text layout shows lines like tid 12345 thread_name: Example log Let's convert it to a more conforming layout: thread_name[12345]: Example log Signed-off-by: Kai Krakow --- lib/chatter.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/chatter.cc b/lib/chatter.cc index 203e06b..cbd5adb 100644 --- a/lib/chatter.cc +++ b/lib/chatter.cc @@ -70,13 +70,15 @@ namespace crucible { header_stream << buf; header_stream << " " << getpid() << "." << gettid() << "<" << m_loglevel << ">"; + if (!m_name.empty()) { + header_stream << " " << m_name; + } } else { - header_stream << "<" << m_loglevel << ">tid " << gettid(); + header_stream << "<" << m_loglevel << ">"; + header_stream << (m_name.empty() ? "thread" : m_name); + header_stream << "[" << gettid() << "]"; } - if (!m_name.empty()) { - header_stream << " " << m_name; - } header_stream << ": "; string out = m_oss.str();