Asynchronous thread-safe logging in C++

后端 未结 5 550
南方客
南方客 2021-02-04 04:04

I\'m looking for a way to do asynchronous and thread-safe logging in my C++ project, if possible to one file. I\'m currently using cerr and clog for th

5条回答
  •  忘掉有多难
    2021-02-04 04:52

    I noticed this 1 year+ old thread. Maybe the asynchronous logger I wrote could be of interest.

    http://www.codeproject.com/KB/library/g2log.aspx

    G2log uses a protected message queue to forward log entries to a background worker that the slow disk accesses.

    I have tried it with a lock-free queue which increased the average time for a LOG call but decreased the worst case time, however I am using the protected queue now as it is cross-platform. It's tested on Windows/Visual Studio 2010 and Ubuntu 11.10/gcc4.6.

    It's released as public domain so you can do with it what you want with no strings attached.

提交回复
热议问题