mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
Optimize logging and make world packet parser callback-safe
This commit is contained in:
parent
85c8b5d5f4
commit
4ea4cb761c
5 changed files with 49 additions and 27 deletions
|
|
@ -16,6 +16,11 @@ Logger& Logger::getInstance() {
|
|||
void Logger::ensureFile() {
|
||||
if (fileReady) return;
|
||||
fileReady = true;
|
||||
if (const char* logStdout = std::getenv("WOWEE_LOG_STDOUT")) {
|
||||
if (logStdout[0] == '0') {
|
||||
echoToStdout_ = false;
|
||||
}
|
||||
}
|
||||
if (const char* flushMs = std::getenv("WOWEE_LOG_FLUSH_MS")) {
|
||||
char* end = nullptr;
|
||||
unsigned long parsed = std::strtoul(flushMs, &end, 10);
|
||||
|
|
@ -67,7 +72,9 @@ void Logger::log(LogLevel level, const std::string& message) {
|
|||
|
||||
line << "] " << message;
|
||||
|
||||
std::cout << line.str() << '\n';
|
||||
if (echoToStdout_) {
|
||||
std::cout << line.str() << '\n';
|
||||
}
|
||||
if (fileStream.is_open()) {
|
||||
fileStream << line.str() << '\n';
|
||||
bool shouldFlush = (level >= LogLevel::WARNING);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue