fmtlog
fmtlog copied to clipboard
Suspected log loss during dense recording
Please test the function in the test as follows, just increasing the RECORDS variable to 1000000.
void runBenchmark() {
const int RECORDS = 1000000;
fmtlog::setLogFile("./log", false);
fmtlog::setLogCB(nullptr, fmtlog::WRN);
std::chrono::high_resolution_clock::time_point t0, t1;
t0 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < RECORDS; ++i) {
logi("Simple log message with one parameters, {}", i);
}
t1 = std::chrono::high_resolution_clock::now();
double span = std::chrono::duration_cast<std::chrono::duration<double>>(t1 - t0).count();
fmt::print("benchmark, front latency: {:.1f} ns/msg average\n", (span / RECORDS) * 1e9);
}
Only 43689 lines are recorded each time.
The log queue can hold 1M bytes data for each thread before poll() is called, in your case each logi(...) pushs 20 bytes data to the queue and it starts to drop logs when the queue is full. If you don't want to drop log you can defining macro FMTLOG_BLOCK=1, but in you test code it will hang forever. It's better to call poll() before the queue is full, but it'll take a little time.
same problem found in my case.
Now log queue full callback is supported: you can be notified when the log queue is full.