From 5161f16f4a60ef976acf4cf29dda89d9fe36e240 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 16 Jan 2017 19:31:43 +0000 Subject: [PATCH 1/2] easylogging++: enforce recursive mutex This fixes a hang when logging something which causes some other logging code to be called --- external/easylogging++/easylogging++.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/external/easylogging++/easylogging++.h b/external/easylogging++/easylogging++.h index 68864845..8042392a 100644 --- a/external/easylogging++/easylogging++.h +++ b/external/easylogging++/easylogging++.h @@ -1001,7 +1001,11 @@ namespace el { public: Mutex(void) { # if ELPP_OS_UNIX - pthread_mutex_init(&m_underlyingMutex, nullptr); + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&m_underlyingMutex, &attr); + pthread_mutexattr_destroy(&attr); # elif ELPP_OS_WINDOWS InitializeCriticalSection(&m_underlyingMutex); # endif // ELPP_OS_UNIX From 5e61687fdf7f626de93515b3b8468a09e9373931 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 16 Jan 2017 19:41:29 +0000 Subject: [PATCH 2/2] mlog: allow overriding log format using the MONERO_LOG_FORMAT environment variable. Default is: %datetime{%Y-%M-%d %H:%m:%s.%g}\t%thread\t%level\t%logger\t%loc\t%msg Field list in easylogging++ documentation. Don't forget to escape as needed. --- contrib/epee/src/mlog.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 37a15bbd..f1d74a2a 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -33,7 +33,6 @@ INITIALIZE_EASYLOGGINGPP -//#define MLOG_BASE_FORMAT "%datetime{%Y-%M-%d %H:%m:%s.%g}\t%thread\t%level\t%logger\t%fbase:%line\t%msg" #define MLOG_BASE_FORMAT "%datetime{%Y-%M-%d %H:%m:%s.%g}\t%thread\t%level\t%logger\t%loc\t%msg" using namespace epee; @@ -83,7 +82,10 @@ void mlog_configure(const std::string &filename_base, bool console) el::Configurations c; c.setGlobally(el::ConfigurationType::Filename, filename_base); c.setGlobally(el::ConfigurationType::ToFile, "true"); - c.setGlobally(el::ConfigurationType::Format, MLOG_BASE_FORMAT); + const char *log_format = getenv("MONERO_LOG_FORMAT"); + if (!log_format) + log_format = MLOG_BASE_FORMAT; + c.setGlobally(el::ConfigurationType::Format, log_format); c.setGlobally(el::ConfigurationType::ToStandardOutput, console ? "true" : "false"); c.setGlobally(el::ConfigurationType::MaxLogFileSize, "104850000"); // 100 MB - 7600 bytes el::Loggers::setDefaultConfigurations(c, true);