mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 03:13:28 +01:00
Reduced executable size; reduced call sequence to "allowed" log function
This commit is contained in:
parent
0b6bfb1fd8
commit
0f2b5af0dd
@ -41,7 +41,7 @@
|
|||||||
#define MAX_LOG_FILES 50
|
#define MAX_LOG_FILES 50
|
||||||
|
|
||||||
#define MCLOG_TYPE(level, cat, color, type, x) do { \
|
#define MCLOG_TYPE(level, cat, color, type, x) do { \
|
||||||
if (ELPP->vRegistry()->allowed(level, cat)) { \
|
if (el::Loggers::allowed(level, cat)) { \
|
||||||
el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
|
el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -89,7 +89,7 @@
|
|||||||
|
|
||||||
#define IFLOG(level, cat, color, type, init, x) \
|
#define IFLOG(level, cat, color, type, init, x) \
|
||||||
do { \
|
do { \
|
||||||
if (ELPP->vRegistry()->allowed(level, cat)) { \
|
if (el::Loggers::allowed(level, cat)) { \
|
||||||
init; \
|
init; \
|
||||||
el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
|
el::base::Writer(level, color, __FILE__, __LINE__, ELPP_FUNC, type).construct(cat) << x; \
|
||||||
} \
|
} \
|
||||||
|
35
external/easylogging++/easylogging++.cc
vendored
35
external/easylogging++/easylogging++.cc
vendored
@ -17,6 +17,7 @@
|
|||||||
#define EASYLOGGING_CC
|
#define EASYLOGGING_CC
|
||||||
#include "easylogging++.h"
|
#include "easylogging++.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(AUTO_INITIALIZE_EASYLOGGINGPP)
|
#if defined(AUTO_INITIALIZE_EASYLOGGINGPP)
|
||||||
@ -2035,7 +2036,7 @@ void RegisteredLoggers::unsafeFlushAll(void) {
|
|||||||
|
|
||||||
// VRegistry
|
// VRegistry
|
||||||
|
|
||||||
VRegistry::VRegistry(base::type::VerboseLevel level, base::type::EnumType* pFlags) : m_level(level), m_pFlags(pFlags), m_lowest_priority(INT_MAX) {
|
VRegistry::VRegistry(base::type::VerboseLevel level, base::type::EnumType* pFlags) : m_level(level), m_pFlags(pFlags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Sets verbose level. Accepted range is 0-9
|
/// @brief Sets verbose level. Accepted range is 0-9
|
||||||
@ -2131,18 +2132,30 @@ static int priority(Level level) {
|
|||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
std::atomic<int> s_lowest_priority{INT_MAX};
|
||||||
|
}
|
||||||
|
|
||||||
|
void VRegistry::clearCategories(void) {
|
||||||
|
const base::threading::ScopedLock scopedLock(lock());
|
||||||
|
m_categories.clear();
|
||||||
|
m_cached_allowed_categories.clear();
|
||||||
|
s_lowest_priority = INT_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
void VRegistry::setCategories(const char* categories, bool clear) {
|
void VRegistry::setCategories(const char* categories, bool clear) {
|
||||||
base::threading::ScopedLock scopedLock(lock());
|
base::threading::ScopedLock scopedLock(lock());
|
||||||
auto insert = [&](std::stringstream& ss, Level level) {
|
auto insert = [&](std::stringstream& ss, Level level) {
|
||||||
m_categories.push_back(std::make_pair(ss.str(), level));
|
m_categories.push_back(std::make_pair(ss.str(), level));
|
||||||
m_cached_allowed_categories.clear();
|
m_cached_allowed_categories.clear();
|
||||||
int pri = priority(level);
|
int pri = priority(level);
|
||||||
if (pri > m_lowest_priority)
|
if (pri > s_lowest_priority)
|
||||||
m_lowest_priority = pri;
|
s_lowest_priority = pri;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (clear) {
|
if (clear) {
|
||||||
m_lowest_priority = 0;
|
s_lowest_priority = 0;
|
||||||
m_categories.clear();
|
m_categories.clear();
|
||||||
m_cached_allowed_categories.clear();
|
m_cached_allowed_categories.clear();
|
||||||
m_categoriesString.clear();
|
m_categoriesString.clear();
|
||||||
@ -2200,9 +2213,9 @@ std::string VRegistry::getCategories() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool VRegistry::allowed(Level level, const std::string &category) {
|
bool VRegistry::allowed(Level level, const std::string &category) {
|
||||||
const int pri = priority(level);
|
return priority_allowed(priority(level), category);
|
||||||
if (pri > m_lowest_priority)
|
}
|
||||||
return false;
|
bool VRegistry::priority_allowed(const int pri, const std::string &category) {
|
||||||
base::threading::ScopedLock scopedLock(lock());
|
base::threading::ScopedLock scopedLock(lock());
|
||||||
const std::map<std::string, int>::const_iterator it = m_cached_allowed_categories.find(category);
|
const std::map<std::string, int>::const_iterator it = m_cached_allowed_categories.find(category);
|
||||||
if (it != m_cached_allowed_categories.end())
|
if (it != m_cached_allowed_categories.end())
|
||||||
@ -3335,6 +3348,14 @@ void Helpers::logCrashReason(int sig, bool stackTraceIfAvailable, Level level, c
|
|||||||
|
|
||||||
// Loggers
|
// Loggers
|
||||||
|
|
||||||
|
bool Loggers::allowed(Level level, const char* cat)
|
||||||
|
{
|
||||||
|
const int pri = base::priority(level);
|
||||||
|
if (pri > base::s_lowest_priority)
|
||||||
|
return false;
|
||||||
|
return ELPP->vRegistry()->priority_allowed(pri, std::string{cat});
|
||||||
|
}
|
||||||
|
|
||||||
Logger* Loggers::getLogger(const std::string& identity, bool registerIfNotAvailable) {
|
Logger* Loggers::getLogger(const std::string& identity, bool registerIfNotAvailable) {
|
||||||
return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable);
|
return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable);
|
||||||
}
|
}
|
||||||
|
12
external/easylogging++/easylogging++.h
vendored
12
external/easylogging++/easylogging++.h
vendored
@ -412,7 +412,6 @@ ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStre
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <atomic>
|
|
||||||
#if ELPP_THREADING_ENABLED
|
#if ELPP_THREADING_ENABLED
|
||||||
# if ELPP_USE_STD_THREADING
|
# if ELPP_USE_STD_THREADING
|
||||||
# include <mutex>
|
# include <mutex>
|
||||||
@ -2464,12 +2463,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
|
|||||||
return m_level;
|
return m_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void clearCategories(void) {
|
void clearCategories(void);
|
||||||
base::threading::ScopedLock scopedLock(lock());
|
|
||||||
m_categories.clear();
|
|
||||||
m_cached_allowed_categories.clear();
|
|
||||||
m_lowest_priority = INT_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void clearModules(void) {
|
inline void clearModules(void) {
|
||||||
base::threading::ScopedLock scopedLock(lock());
|
base::threading::ScopedLock scopedLock(lock());
|
||||||
@ -2482,6 +2476,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
|
|||||||
|
|
||||||
void setModules(const char* modules);
|
void setModules(const char* modules);
|
||||||
|
|
||||||
|
bool priority_allowed(int priority, const std::string &category);
|
||||||
bool allowed(Level level, const std::string &category);
|
bool allowed(Level level, const std::string &category);
|
||||||
|
|
||||||
bool allowed(base::type::VerboseLevel vlevel, const char* file);
|
bool allowed(base::type::VerboseLevel vlevel, const char* file);
|
||||||
@ -2513,7 +2508,6 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
|
|||||||
std::map<std::string, int> m_cached_allowed_categories;
|
std::map<std::string, int> m_cached_allowed_categories;
|
||||||
std::string m_categoriesString;
|
std::string m_categoriesString;
|
||||||
std::string m_filenameCommonPrefix;
|
std::string m_filenameCommonPrefix;
|
||||||
std::atomic<int> m_lowest_priority;
|
|
||||||
};
|
};
|
||||||
} // namespace base
|
} // namespace base
|
||||||
class LogMessage {
|
class LogMessage {
|
||||||
@ -3868,6 +3862,8 @@ class Helpers : base::StaticClass {
|
|||||||
/// @brief Static helpers to deal with loggers and their configurations
|
/// @brief Static helpers to deal with loggers and their configurations
|
||||||
class Loggers : base::StaticClass {
|
class Loggers : base::StaticClass {
|
||||||
public:
|
public:
|
||||||
|
/// @brief Determines whether logging will occur at this level and category
|
||||||
|
static bool allowed(Level leve, const char* cat);
|
||||||
/// @brief Gets existing or registers new logger
|
/// @brief Gets existing or registers new logger
|
||||||
static Logger* getLogger(const std::string& identity, bool registerIfNotAvailable = true);
|
static Logger* getLogger(const std::string& identity, bool registerIfNotAvailable = true);
|
||||||
/// @brief Changes default log builder for future loggers
|
/// @brief Changes default log builder for future loggers
|
||||||
|
Loading…
Reference in New Issue
Block a user