Small logger class

后端 未结 9 1484
再見小時候
再見小時候 2020-12-12 17:24

I am looking for a small lightweight logging system in c++. I have found some existing frameworks but I don\'t need all of their features at this point in time. I primarily

9条回答
  •  青春惊慌失措
    2020-12-12 18:17

    I, as well as many others, also answered this question with some code.

    This isn't really "ready" in all ways, but it could be easily modified:

    https://gist.github.com/earonesty/977b14c93358fe9b9ee674baac5d42d7

    Features:

    • writing to the log doesn't block on i/o
    • similar macros to other solutions (LOGE(blah << stream))
    • prefers discarding log entries to slowing down
    • lazy flushing
    • header only, very small, stl classes only
    • tested on osx/win/nix
    • time format is configurable

    Missing stuff:

    • easy, flexible log formatting (predefining a macro would be fine)
    • triggers have an interface but don't work yet
    • microseconds aren't working yet

    If anyone actually likes this solution in any way, lmk and I'll make a real repo out of it with tests, etc. It's pretty fast. Probably not as fast as speedlogger (a heavier feature complete library), but not sure.

提交回复
热议问题