39 std::lock_guard<std::recursive_mutex> lock(m_mutex);
46 static bool ignoreLogs =
false;
50 const static std::string logPrefixes[] = {
"",
"",
"WARNING: ",
"ERROR: ",
"FATAL ERROR: " };
52 std::string outmsg = logPrefixes[level] + message;
70 std::cout << outmsg << std::endl;
72 if(m_outFile.good()) {
73 m_outFile << outmsg << std::endl;
78 m_logMessages.emplace_back(level, outmsg, now);
79 if(m_logMessages.size() > MAX_LOG_HISTORY)
80 m_logMessages.pop_front();
86 m_onLog(level, outmsg, now);
101 std::lock_guard<std::recursive_mutex> lock(m_mutex);
103 prettyFunction = prettyFunction.substr(0, prettyFunction.find_first_of(
'('));
104 if(prettyFunction.find_last_of(
' ') != std::string::npos)
105 prettyFunction = prettyFunction.substr(prettyFunction.find_last_of(
' ') + 1);
108 std::stringstream ss;
111 if(!prettyFunction.empty()) {
117 log(level, ss.str());
122 std::lock_guard<std::recursive_mutex> lock(m_mutex);
125 auto backup = m_logMessages;
127 m_onLog(logMessage.level, logMessage.message, logMessage.when);
134 std::lock_guard<std::recursive_mutex> lock(m_mutex);
137 if(!m_outFile.is_open() || !m_outFile.good()) {