mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 11:23:26 +01:00
easylogging++: allow setting thread names
This commit is contained in:
parent
ec71ce8d2d
commit
2836284798
17
external/easylogging++/easylogging++.h
vendored
17
external/easylogging++/easylogging++.h
vendored
@ -3971,11 +3971,22 @@ inline void FUNCTION_NAME(const T&);
|
|||||||
return !base::utils::hasFlag(LoggingFlag::DisableVModules, *m_pFlags);
|
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:
|
private:
|
||||||
base::type::VerboseLevel m_level;
|
base::type::VerboseLevel m_level;
|
||||||
base::type::EnumType* m_pFlags;
|
base::type::EnumType* m_pFlags;
|
||||||
std::map<std::string, base::type::VerboseLevel> m_modules;
|
std::map<std::string, base::type::VerboseLevel> m_modules;
|
||||||
std::deque<std::pair<std::string, Level>> m_categories;
|
std::deque<std::pair<std::string, Level>> m_categories;
|
||||||
|
std::map<std::string, std::string> m_threadNames;
|
||||||
};
|
};
|
||||||
} // namespace base
|
} // namespace base
|
||||||
class LogMessage {
|
class LogMessage {
|
||||||
@ -4530,7 +4541,7 @@ inline void FUNCTION_NAME(const T&);
|
|||||||
if (logFormat->hasFlag(base::FormatFlags::ThreadId)) {
|
if (logFormat->hasFlag(base::FormatFlags::ThreadId)) {
|
||||||
// Thread ID
|
// Thread ID
|
||||||
base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kThreadIdFormatSpecifier,
|
base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kThreadIdFormatSpecifier,
|
||||||
base::threading::getCurrentThreadId());
|
ELPP->vRegistry()->getThreadName(base::threading::getCurrentThreadId()));
|
||||||
}
|
}
|
||||||
if (logFormat->hasFlag(base::FormatFlags::DateTime)) {
|
if (logFormat->hasFlag(base::FormatFlags::DateTime)) {
|
||||||
// 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) {
|
static inline void setCategories(const char* categories, bool clear = true) {
|
||||||
ELPP->vRegistry()->setCategories(categories, clear);
|
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
|
/// @brief Clears vmodules
|
||||||
static inline void clearVModules(void) {
|
static inline void clearVModules(void) {
|
||||||
ELPP->vRegistry()->clearModules();
|
ELPP->vRegistry()->clearModules();
|
||||||
|
Loading…
Reference in New Issue
Block a user