void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *file, int line, const char *format, va_list args) { std::lock_guard<std::mutex> lk(m_log_lock); char msg[MAX_MSGLEN * 2]; LogContainer *log = m_Log[type]; if (!log || !log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) return; static const char level_to_char[7] = "-NEWID"; char formattedTime[13]; Common::Timer::GetTimeFormatted(formattedTime); char *msgPos = msg; msgPos += sprintf(msgPos, "%s %s:%d %c[%s]: ", formattedTime, file, line, level_to_char[(int)level], log->GetShortName()); msgPos += vsnprintf(msgPos, MAX_MSGLEN, format, args); // This will include the null terminator. memcpy(msgPos, "\n", sizeof("\n")); log->Trigger(level, msg); }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *file, int line, const char *format, va_list args) { std::lock_guard<std::mutex> lk(m_log_lock); char msg[MAX_MSGLEN * 2]; LogContainer *log = m_Log[type]; if (!log || !log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) return; static const char level_to_char[8] = "-NEWIDV"; char formattedTime[13]; Common::Timer::GetTimeFormatted(formattedTime); #ifdef _DEBUG #ifdef _WIN32 static const char sep = '\\'; #else static const char sep = '/'; #endif const char *fileshort = strrchr(file, sep); if (fileshort != NULL) { do --fileshort; while (fileshort > file && *fileshort != sep); if (fileshort != file) file = fileshort + 1; } #endif char *msgPos = msg; if (hleCurrentThreadName != NULL) { msgPos += sprintf(msgPos, "%s %-12.12s %c[%s]: %s:%d ", formattedTime, hleCurrentThreadName, level_to_char[(int)level], log->GetShortName(), file, line); } else { msgPos += sprintf(msgPos, "%s %s:%d %c[%s]: ", formattedTime, file, line, level_to_char[(int)level], log->GetShortName()); } msgPos += vsnprintf(msgPos, MAX_MSGLEN, format, args); // This will include the null terminator. memcpy(msgPos, "\n", sizeof("\n")); log->Trigger(level, msg); }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *file, int line, const char *format, va_list args) { char temp[MAX_MSGLEN]; LogContainer *log = m_Log[type]; if (!log->IsEnabled() || level > log->GetLevel() || !log->HasListeners()) return; CharArrayFromFormatV(temp, MAX_MSGLEN, format, args); std::string msg = StringFromFormat("%s %s:%u %c[%s]: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, LogTypes::LOG_LEVEL_TO_CHAR[(int)level], log->GetShortName().c_str(), temp); for (auto listener_id : *log) m_listeners[listener_id]->Log(level, msg.c_str()); }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line, const char* function, const char *fmt, va_list args) { char temp[MAX_MSGLEN]; char msg[MAX_MSGLEN * 2]; LogContainer *log = m_Log[type]; if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) return; Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); static const char level_to_char[7] = "ONEWID"; sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, level_to_char[(int)level], log->GetShortName(), function, temp); #ifdef ANDROID Host_SysMessage(msg); #endif log->Trigger(level, msg); }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char *file, int line, const char *format, va_list args) { std::lock_guard<std::mutex> lk(m_log_lock); char temp[MAX_MSGLEN]; char msg[MAX_MSGLEN * 2]; LogContainer *log = m_Log[type]; if (!log || !log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners()) return; CharArrayFromFormatV(temp, MAX_MSGLEN, format, args); static const char level_to_char[7] = "-NEWID"; char formattedTime[13]; Common::Timer::GetTimeFormatted(formattedTime); sprintf(msg, "%s %s:%d %c[%s]: %s\n", formattedTime, file, line, level_to_char[(int)level], log->GetShortName(), temp); log->Trigger(level, msg); }