MengRao / fmtlog

fmtlog is a performant fmtlib-style logging library with latency in nanoseconds.
MIT License
784 stars 118 forks source link

Suggestion: application-defined queue size #70

Closed tmartin-gh closed 1 year ago

tmartin-gh commented 1 year ago

It would be useful for the application (perhaps in the preallocate() call) to be able to change the default ~1MB queue size, I.e. the BLK_CNT parameter.

In many circumstances, it is effective to reduce the polling interval instead. But there can be times of bursty logs in some applications where it isn’t feasible to reduce the polling interval and increasing buffer size works better.

Another alternative to prevent log dropping is using FMTLOG_BLOCK=1 to block the log-enqueuing thread, but again in times of very bursty logging it may be necessary to allow the log-enqueuing thread to run without blocking and use more buffer memory.

MengRao commented 1 year ago

Just made log queue size configurable by adding macro FMTLOG_QUEUE_SIZE, please check the latest commit.