diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-12-11 13:23:06 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-01-16 00:17:55 +0000 |
commit | 2836284798ab448babc3f44b2715cb1d8183d9c4 (patch) | |
tree | a92d8e62d2ca886c9319f2eefe3753811d08f4ca /external/easylogging++/easylogging++.h | |
parent | easylogging++: Print thread ID in a nicer way (diff) | |
download | monero-2836284798ab448babc3f44b2715cb1d8183d9c4.tar.xz |
easylogging++: allow setting thread names
Diffstat (limited to 'external/easylogging++/easylogging++.h')
-rw-r--r-- | external/easylogging++/easylogging++.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/external/easylogging++/easylogging++.h b/external/easylogging++/easylogging++.h index 3b61ee0c2..ccea24d2e 100644 --- a/external/easylogging++/easylogging++.h +++ b/external/easylogging++/easylogging++.h @@ -3970,12 +3970,23 @@ inline void FUNCTION_NAME(const T&); inline bool vModulesEnabled(void) { return !base::utils::hasFlag(LoggingFlag::DisableVModules, *m_pFlags); } + + void setThreadName(const std::string &name) { + m_threadNames[base::threading::getCurrentThreadId()] = name; + } + std::string getThreadName(const std::string& name) { + std::map<std::string, std::string>::const_iterator it = m_threadNames.find(name); + if (it == m_threadNames.end()) + return name; + return it->second; + } private: base::type::VerboseLevel m_level; base::type::EnumType* m_pFlags; std::map<std::string, base::type::VerboseLevel> m_modules; std::deque<std::pair<std::string, Level>> m_categories; + std::map<std::string, std::string> m_threadNames; }; } // namespace base class LogMessage { @@ -4530,7 +4541,7 @@ inline void FUNCTION_NAME(const T&); if (logFormat->hasFlag(base::FormatFlags::ThreadId)) { // Thread ID base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kThreadIdFormatSpecifier, - base::threading::getCurrentThreadId()); + ELPP->vRegistry()->getThreadName(base::threading::getCurrentThreadId())); } if (logFormat->hasFlag(base::FormatFlags::DateTime)) { // DateTime @@ -6121,6 +6132,10 @@ el::base::type::ostream_t& operator<<(el::base::type::ostream_t& OutputStreamIns static inline void setCategories(const char* categories, bool clear = true) { ELPP->vRegistry()->setCategories(categories, clear); } + /// @brief Sets thread name (to replace ID) + static inline void setThreadName(const std::string &name) { + ELPP->vRegistry()->setThreadName(name); + } /// @brief Clears vmodules static inline void clearVModules(void) { ELPP->vRegistry()->clearModules(); |