Open gaborcsardi opened 7 years ago
I use plogr for C++ logging, which has zero impact if turned off at compile time and low impact if turned off at run time.
That's not bad. But I also want it to work the same way. I.e.
DEBUGME
environment variableWant to spend a couple of hours in Brussels integrating these two packages?
This would be handy for me now, but I need a solution that works in pure C code (as well). For plog
, I would need to embed it into a C library, right?
plogr calls currently look like LOG_VERBOSE << expression;
, so we'd need a whole new API for this, maybe printf-based?
Yeah, vsnprintf
I guess.
And we would also need to embed the C lib into debugme
or plogr
...
plogr is header-only, can we do the same with C?
How about starting the C API in debugme, and then adapting the plogr API to use the debugme C API under the hood, or move the plogr API to debugme?
plogr is header-only, can we do the same with C?
I guess we could, but not if we use plog
/ plogr
. I don't see how we could do it without requiring a C++ compiler. Which is bad. But FIXME.
I'd suggest to independently start a C header-only implementation in debugme, with env var triggers and color, and then see how to include the rather nice C++ API, but maybe without the rest of plog.
OTOH, it would be just easier to use sg like https://github.com/wonder-mice/zf_log
Yeah, I'd suggest to use a header-only library, though.
I am not sure if there is a header only C logging library.
Maybe it's sufficient if the header contains everything necessary to decide if a log event happens, and then we use R callbacks to forward to debugme?
I would avoid calling back to R if possible....
I think there is no other sensible way, but define a proper C API using R_RegisterCCallable
.
That's what I meant ;-)
Do you agree that the logic that decides if anything is logged needs to be in the header file? How do we make this fast, ideally one memory read and one conditional jump?
Yes, sure, those must be macros.
Would be nice.