crash test 2
This commit is contained in:
parent
14e70e2684
commit
45f9aa7261
12
src/log.cpp
12
src/log.cpp
|
@ -29,8 +29,8 @@ int logLevel=LOGLEVEL_INFO;
|
||||||
|
|
||||||
FILE* logFile;
|
FILE* logFile;
|
||||||
char* logFileBuf;
|
char* logFileBuf;
|
||||||
std::atomic<unsigned int> logFilePosI;
|
unsigned int logFilePosI;
|
||||||
std::atomic<unsigned int> logFilePosO;
|
unsigned int logFilePosO;
|
||||||
std::thread* logFileThread;
|
std::thread* logFileThread;
|
||||||
std::mutex logFileLock;
|
std::mutex logFileLock;
|
||||||
std::mutex logFileLockI;
|
std::mutex logFileLockI;
|
||||||
|
@ -67,7 +67,9 @@ void appendLogBuf(const LogEntry& entry) {
|
||||||
const char* msg=toWrite.c_str();
|
const char* msg=toWrite.c_str();
|
||||||
size_t len=toWrite.size();
|
size_t len=toWrite.size();
|
||||||
|
|
||||||
int remaining=(logFilePosO-logFilePosI)&TA_LOGFILE_BUF_SIZE;
|
printf("appendLogBuf %d %d\n",logFilePosI,(int)len);
|
||||||
|
|
||||||
|
int remaining=(logFilePosO-logFilePosI-1)&TA_LOGFILE_BUF_SIZE;
|
||||||
|
|
||||||
if (len>=(unsigned int)remaining) {
|
if (len>=(unsigned int)remaining) {
|
||||||
printf("line too long to fit in log buffer!\n");
|
printf("line too long to fit in log buffer!\n");
|
||||||
|
@ -92,6 +94,8 @@ int writeLog(int level, const char* msg, fmt::printf_args args) {
|
||||||
int pos=logPosition;
|
int pos=logPosition;
|
||||||
logPosition=(logPosition+1)&TA_LOG_MASK;
|
logPosition=(logPosition+1)&TA_LOG_MASK;
|
||||||
|
|
||||||
|
printf("logPosition: %d\n",pos);
|
||||||
|
|
||||||
logEntries[pos].text=fmt::vsprintf(msg,args);
|
logEntries[pos].text=fmt::vsprintf(msg,args);
|
||||||
// why do I have to pass a pointer
|
// why do I have to pass a pointer
|
||||||
// can't I just pass the time_t directly?!
|
// can't I just pass the time_t directly?!
|
||||||
|
@ -166,8 +170,6 @@ void _logFileThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startLogFile(const char* path) {
|
bool startLogFile(const char* path) {
|
||||||
logFileAvail=false;
|
|
||||||
return false;
|
|
||||||
if (logFileAvail) return true;
|
if (logFileAvail) return true;
|
||||||
|
|
||||||
// rotate log file if possible
|
// rotate log file if possible
|
||||||
|
|
Loading…
Reference in a new issue