MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / logMessage

Method logMessage

source/utils/LogManager.cpp:55–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void LogManager::logMessage(LogMessageLevel level, const char* filepath, int line, const std::string& message)
56{
57 sf::Lock locked(mLock);
58
59 // module
60
61 const boost::filesystem::path strippedPath(filepath);
62 std::string module = strippedPath.stem().string();
63
64 // Check if the message fails the global threshold.
65
66 if (mLevel > level)
67 {
68 // Allow per-module overrides of the global logging level.
69
70 if (mModuleLevel.empty())
71 {
72 return;
73 }
74
75 auto found = mModuleLevel.find(module);
76 if (found == mModuleLevel.end() ||
77 found->second > level)
78 {
79 return;
80 }
81 }
82
83 // filename
84
85 std::string filename = strippedPath.filename().string();
86
87 // timestamp
88
89 time_t current_time = ::time(0);
90 struct tm* now = ::localtime(&current_time);
91
92 mTimestampStream.str("");
93 mTimestampStream
94 << std::setfill('0') << std::setw(2) << now->tm_hour << ':'
95 << std::setfill('0') << std::setw(2) << now->tm_min << ':'
96 << std::setfill('0') << std::setw(2) << now->tm_sec;
97
98 std::string timestamp = mTimestampStream.str();
99
100 for (const auto& sink : mSinks)
101 {
102 sink->write(level, module, timestamp, filename, line, message);
103 }
104}

Callers 4

exceptionFilterMethod · 0.80
writeMethod · 0.80
exceptionFilterMethod · 0.80
critErrHandlerMethod · 0.80

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected