Sorry but I think I'd like to go now.

This commit is contained in:
tildearrow 2022-04-11 00:12:24 -05:00
parent 92b8703574
commit 9e0e725802
6 changed files with 11 additions and 34 deletions

View file

@ -90,11 +90,16 @@ int logE(const char* format, ...) {
}
int writeLog(int level, const char* msg, fmt::printf_args& args) {
time_t thisMakesNoSense=time(NULL);
int pos=logPosition;
logPosition=(logPosition+1)&TA_LOG_MASK;
logEntries[pos].text=fmt::vsprintf(msg,args);
logEntries[pos].time=std::chrono::system_clock::now();
// why do I have to pass a pointer
// can't I just pass the time_t directly?!
if (localtime_r(&thisMakesNoSense,&logEntries[pos].time)==NULL) {
memset(&logEntries[pos].time,0,sizeof(struct tm));
}
logEntries[pos].loglevel=level;
logEntries[pos].ready=true;
@ -119,4 +124,4 @@ void initLog() {
for (int i=0; i<TA_LOG_SIZE; i++) {
logEntries[i].text.reserve(128);
}
}
}