emilk / loguru

A lightweight C++ logging library
The Unlicense
1.77k stars 256 forks source link

Include fmt/ostream when using fmtlib #148

Closed richardhozak closed 2 years ago

richardhozak commented 4 years ago

This allows us to print user defined classes/struct that have only ostream operator defined.

emilk commented 4 years ago

Could a user call #include <fmt/ostream.h> themselves before/after #include <loguru.hpp>? If so, I would prefer that.

One of the stated goals of Loguru is to keep the number of headers it includes down to a minimum (down to zero in the default case) to keep compile times down.

In the fmtlib path of Loguru there already are a few headers #included, but how much more gets included by this? If <fmt/ostream.h> is tiny (and doesn't include more itself) then this PR is probably fine.

You can use -E option to clang/gcc to measure how much extra code is #included to loguru.hpp by this.

richardhozak commented 4 years ago

<fmt/ostream.h> includes fmt/format. which is already included in loguru.hpp and also includes <ostream>: https://github.com/fmtlib/fmt/blob/master/include/fmt/ostream.h.

One of the stated goals of Loguru is to keep the number of headers it includes down to a minimum (down to zero in the default case) to keep compile times down.

I get it, I chose loguru instead of spdlog because of this, I am migrating from it, so I used the fmtlib support in loguru, this is the last thing I need, so I do not have to include fmt/ostream everywhere. It behaves exactly like spdlog, but is a bit lighter.