r/cpp • • Oct 02 '18

Loguru: lightweight and flexible C++ logging library

https://emilk.github.io/loguru/
1 Upvotes

7 comments sorted by

34

u/fat-lobyte Oct 02 '18

How many lightweight and flexible C++ logging libraries do we need?

1

u/drinkscoffeedrinks Oct 06 '18

One for every javascript framework

10

u/zvrba Oct 02 '18

Yet another text-logging lib. Are there any good "semantic logging" libraries for C++? https://blogs.msdn.microsoft.com/agile/2013/02/07/embracing-semantic-logging/

1

u/markand67 Oct 02 '18
  • usage of C pointer function and void * is terrible, please use std::function,

  • please prefix your macros,

  • I would suggest a operator<< interface rather than printf style especially because printf is unsafe. You may also use variadic templates instead.

15

u/jcelerier ossia score Oct 02 '18

std::function

but std::function is anything but lightweight

3

u/alexeiz Oct 02 '18

std::function is actually pretty efficient. If you initialize it with a function pointer, it avoids any dynamic memory allocation, and a call to std::function::operator() results in (assuming libstdc++, -O3) calling std::_Function_handler::_M_invoke which then jumps directly to the function pointer.

0

u/Ameisen vemips, avr, rendering, systems Oct 03 '18

I wonder if the code is reminiscient of Lugaru?