mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
log: Prefix log messages with function name if -logsourcelocations is set
This commit is contained in:
@@ -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() + "] ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user