mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
make nest levels thread local
This commit is contained in:
parent
e5db59535d
commit
aadc7efdd6
2 changed files with 12 additions and 12 deletions
|
@ -197,9 +197,9 @@ void Logger::push(Severity sev, Mod* mod, std::string&& content) {
|
|||
log = &m_logs.emplace_back(sev, mod, std::move(content));
|
||||
}
|
||||
|
||||
auto nestCount = m_nestLevel * 2;
|
||||
auto nestCount = s_nestLevel * 2;
|
||||
if (nestCount != 0) {
|
||||
nestCount += m_nestCountOffset;
|
||||
nestCount += s_nestCountOffset;
|
||||
}
|
||||
|
||||
auto const logStr = log->toString(true, nestCount);
|
||||
|
@ -209,13 +209,13 @@ void Logger::push(Severity sev, Mod* mod, std::string&& content) {
|
|||
}
|
||||
|
||||
void Logger::pushNest() {
|
||||
if (m_nestLevel == 0)
|
||||
m_nestCountOffset = static_cast<int32_t>(Mod::get()->getName().size());
|
||||
m_nestLevel++;
|
||||
if (s_nestLevel == 0)
|
||||
s_nestCountOffset = static_cast<int32_t>(Mod::get()->getName().size());
|
||||
s_nestLevel++;
|
||||
}
|
||||
|
||||
void Logger::popNest() {
|
||||
m_nestLevel--;
|
||||
s_nestLevel--;
|
||||
}
|
||||
|
||||
std::vector<Log> const& Logger::list() {
|
||||
|
@ -234,9 +234,9 @@ std::string geode::log::generateLogName() {
|
|||
}
|
||||
|
||||
void log::pushNest() {
|
||||
Logger::get()->pushNest();
|
||||
Logger::pushNest();
|
||||
}
|
||||
|
||||
void log::popNest() {
|
||||
Logger::get()->popNest();
|
||||
Logger::popNest();
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace geode::log {
|
|||
private:
|
||||
std::vector<Log> m_logs;
|
||||
std::ofstream m_logStream;
|
||||
int32_t m_nestLevel;
|
||||
int32_t m_nestCountOffset;
|
||||
static thread_local int32_t s_nestLevel;
|
||||
static thread_local int32_t s_nestCountOffset;
|
||||
|
||||
Logger() {}
|
||||
public:
|
||||
|
@ -43,8 +43,8 @@ namespace geode::log {
|
|||
// why would you need this lol
|
||||
// void pop(Log* log);
|
||||
|
||||
void pushNest();
|
||||
void popNest();
|
||||
static void pushNest();
|
||||
static void popNest();
|
||||
|
||||
std::vector<Log> const& list();
|
||||
void clear();
|
||||
|
|
Loading…
Reference in a new issue