From 5bab044984be78e5e71cf5e0b7f1ef043f6091b1 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 25 Mar 2017 19:42:12 +0000 Subject: [PATCH] easylogging++: add file-only logs --- external/easylogging++/easylogging++.cc | 20 +++++++++++--------- external/easylogging++/easylogging++.h | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/external/easylogging++/easylogging++.cc b/external/easylogging++/easylogging++.cc index f40658096..1fca50678 100644 --- a/external/easylogging++/easylogging++.cc +++ b/external/easylogging++/easylogging++.cc @@ -2183,11 +2183,11 @@ void Storage::setApplicationArguments(int argc, char** argv) { void DefaultLogDispatchCallback::handle(const LogDispatchData* data) { m_data = data; dispatch(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(), - m_data->dispatchAction() == base::DispatchAction::NormalLog)); + m_data->dispatchAction() == base::DispatchAction::NormalLog || m_data->dispatchAction() == base::DispatchAction::FileOnlyLog)); } void DefaultLogDispatchCallback::dispatch(base::type::string_t&& logLine) { - if (m_data->dispatchAction() == base::DispatchAction::NormalLog) { + if (m_data->dispatchAction() == base::DispatchAction::NormalLog || m_data->dispatchAction() == base::DispatchAction::FileOnlyLog) { if (m_data->logMessage()->logger()->m_typedConfigurations->toFile(m_data->logMessage()->level())) { base::type::fstream_t* fs = m_data->logMessage()->logger()->m_typedConfigurations->fileStream( m_data->logMessage()->level()); @@ -2210,10 +2210,12 @@ void DefaultLogDispatchCallback::dispatch(base::type::string_t&& logLine) { << m_data->logMessage()->logger()->id() << "]", false); } } - if (m_data->logMessage()->logger()->m_typedConfigurations->toStandardOutput(m_data->logMessage()->level())) { - if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput)) - m_data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, m_data->logMessage()->level()); - ELPP_COUT << ELPP_COUT_LINE(logLine); + if (m_data->dispatchAction() != base::DispatchAction::FileOnlyLog) { + if (m_data->logMessage()->logger()->m_typedConfigurations->toStandardOutput(m_data->logMessage()->level())) { + if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput)) + m_data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, m_data->logMessage()->level()); + ELPP_COUT << ELPP_COUT_LINE(logLine); + } } } #if defined(ELPP_SYSLOG) @@ -2249,8 +2251,8 @@ void DefaultLogDispatchCallback::dispatch(base::type::string_t&& logLine) { void AsyncLogDispatchCallback::handle(const LogDispatchData* data) { base::type::string_t logLine = data->logMessage()->logger()->logBuilder()->build(data->logMessage(), - data->dispatchAction() == base::DispatchAction::NormalLog); - if (data->dispatchAction() == base::DispatchAction::NormalLog + data->dispatchAction() == base::DispatchAction::NormalLog || data->dispatchAction() == base::DispatchAction::FileOnlyLog); + if ((data->dispatchAction() == base::DispatchAction::NormalLog || data->dispatchAction() == base::DispatchAction::FileOnlyLog) && data->logMessage()->logger()->typedConfigurations()->toStandardOutput(data->logMessage()->level())) { if (ELPP->hasFlag(LoggingFlag::ColoredTerminalOutput)) data->logMessage()->logger()->logBuilder()->convertToColoredOutput(&logLine, data->logMessage()->level()); @@ -2305,7 +2307,7 @@ void AsyncDispatchWorker::handle(AsyncLogItem* logItem) { Logger* logger = logMessage->logger(); base::TypedConfigurations* conf = logger->typedConfigurations(); base::type::string_t logLine = logItem->logLine(); - if (data->dispatchAction() == base::DispatchAction::NormalLog) { + if (data->dispatchAction() == base::DispatchAction::NormalLog || data->dispatchAction() == base::DispatchAction::FileOnlyLog) { if (conf->toFile(logMessage->level())) { base::type::fstream_t* fs = conf->fileStream(logMessage->level()); if (fs != nullptr) { diff --git a/external/easylogging++/easylogging++.h b/external/easylogging++/easylogging++.h index 615314036..f4573fb80 100644 --- a/external/easylogging++/easylogging++.h +++ b/external/easylogging++/easylogging++.h @@ -2183,7 +2183,7 @@ class RegisteredHitCounters : public base::utils::RegistryWithPred