Closed liss-h closed 9 months ago
I'm glad that you were able to find a way to support custom loggers keeping the header-only design. I also like the level_filter
design.
I'm going to accept this PR.
Future work:
I'm wondering if there is a way to avoid not using logger_interface.h
file with C++ so that metall_log
or metall_log_level
is not declared in the global space. I'll think about it.
Hi, this PR implements the ability to implement custom loggers in consuming applications. I've tried to keep the changes minimal, but there is still some room to make them even more minimal (see notes for details).
Some Notes:
METALL_LOGGER_EXTERN_C=1
and then provide a defintion formetall_log
somewhere. If you don't like how that works, feel free to suggest something elsemetall_log
is intentionally anextern "C"
interface so that it can be easily used in FFI/cross-language contexts, i.e. this gives the ability to implement the logger behaviour in a foreign language that is notC
orC++
, which has the advantage of having the ability to neatly integrate into the native logging interface of the foreign languagesilent
loggerlevel
and factored it out into thelevel_filter
. The reason being thatsilent
is not really a log level and there isn't really a point in ever logging silent messages, because they are always ignored. But of course this is an interface change so I would understand if you didn't like it, in that case I can revert this detail back to its original state. Otherwise no change in interface has occured (in the default configuration)This is related to #297