aboutsummaryrefslogtreecommitdiff
path: root/src/logging.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2020-08-25 20:22:28 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2021-01-15 09:57:32 +0000
commitb4511e2e2ed1a6077ae6826a9ee6b7a311293d08 (patch)
treeb6191e31029db4e1e517f93e4af119015d159c2e /src/logging.cpp
parent29d2aeb4a2b1830be4724aab3a84a62f072056f4 (diff)
downloadbitcoin-b4511e2e2ed1a6077ae6826a9ee6b7a311293d08.tar.xz
log: Prefix log messages with function name if -logsourcelocations is set
Diffstat (limited to 'src/logging.cpp')
-rw-r--r--src/logging.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/logging.cpp b/src/logging.cpp
index 4ddcf1d930..e175fc3d5e 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -5,6 +5,7 @@
#include <logging.h>
#include <util/threadnames.h>
+#include <util/string.h>
#include <util/time.h>
#include <mutex>
@@ -236,11 +237,15 @@ namespace BCLog {
}
}
-void BCLog::Logger::LogPrintStr(const std::string& str)
+void BCLog::Logger::LogPrintStr(const std::string& str, const std::string& logging_function, const std::string& source_file, const int source_line)
{
StdLockGuard scoped_lock(m_cs);
std::string str_prefixed = LogEscapeMessage(str);
+ if (m_log_sourcelocations && m_started_new_line) {
+ str_prefixed.insert(0, "[" + RemovePrefix(source_file, "./") + ":" + ToString(source_line) + "] [" + logging_function + "] ");
+ }
+
if (m_log_threadnames && m_started_new_line) {
str_prefixed.insert(0, "[" + util::ThreadGetInternalName() + "] ");
}