MCPcopy Index your code
hub / github.com/assaultcube/AC / xlog

Function xlog

source/src/log.cpp:175–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void xlog(int level, const char *msg, ...) // log line from any thread (more expensive: only use for functions, that are called from main and other threads)
176{
177 ASSERT(level >= 0 && level < ACLOG_NUM);
178 if(!loglevelenabled[level]) return;
179 bool ismain = ismainthread();
180 if(ismain)
181 {
182 if(mainlog.full()) { mainlogoverflow++; return; } // do. not. block.
183 }
184 else
185 {
186 threadlogsem.wait(); // properly lock, so different threads can use this
187 while(threadlog.full()) threadlogfullsem.wait(); // wait for buffer to clear
188 }
189 logline_s *ll = ismain ? mainlog.stage(new logline_s) : threadlog.stage(new logline_s);
190 vformatstring(ll->msg, msg, msg);
191 filtertext(ll->msg, ll->msg, FTXT__LOG);
192 ll->t = time(NULL);
193 ll->level = level;
194 if(ismain)
195 {
196 mainlog.commit();
197 if(mainlogsem.getvalue() < 1) mainlogsem.post();
198 }
199 else
200 {
201 threadlog.commit();
202 threadlogsem.post();
203 }
204}
205
206extern int stat_theadlog_peaklevel;
207

Callers 8

checkclientposFunction · 0.85
loopvFunction · 0.85
check_ffireFunction · 0.85
loadMethod · 0.85
mapactionMethod · 0.85
connectmasterFunction · 0.85
processmasterinputFunction · 0.85
fatalFunction · 0.85

Calls 8

ismainthreadFunction · 0.85
filtertextFunction · 0.85
fullMethod · 0.80
waitMethod · 0.80
stageMethod · 0.80
commitMethod · 0.80
getvalueMethod · 0.80
postMethod · 0.80

Tested by

no test coverage detected