MCPcopy Create free account
hub / github.com/ddnet/ddnet / Log

Method Log

src/base/log.cpp:230–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228 {
229 }
230 void Log(const CLogMessage *pMessage) override
231 {
232 if(m_Filter.Filters(pMessage))
233 {
234 return;
235 }
236 aio_lock(m_pAio);
237 if(m_AnsiTruecolor && pMessage->m_HaveColor)
238 {
239 // https://en.wikipedia.org/w/index.php?title=ANSI_escape_code&oldid=1077146479#24-bit
240 char aAnsi[32];
241 str_format(aAnsi, sizeof(aAnsi),
242 "\x1b[38;2;%d;%d;%dm",
243 pMessage->m_Color.r,
244 pMessage->m_Color.g,
245 pMessage->m_Color.b);
246 aio_write_unlocked(m_pAio, aAnsi, str_length(aAnsi));
247 }
248 aio_write_unlocked(m_pAio, pMessage->m_aLine, pMessage->m_LineLength);
249 if(m_AnsiTruecolor && pMessage->m_HaveColor)
250 {
251 const char aResetColor[] = "\x1b[0m";
252 aio_write_unlocked(m_pAio, aResetColor, str_length(aResetColor)); // reset
253 }
254 aio_write_newline_unlocked(m_pAio);
255 aio_unlock(m_pAio);
256 }
257 ~CLoggerAsync() override
258 {
259 if(m_Close)

Callers

nothing calls this directly

Calls 5

str_formatFunction · 0.85
aio_write_unlockedFunction · 0.85
str_lengthFunction · 0.85
FiltersMethod · 0.80

Tested by

no test coverage detected