Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C/C++ API #16

Open
gaborcsardi opened this issue Jun 12, 2017 · 17 comments
Open

C/C++ API #16

gaborcsardi opened this issue Jun 12, 2017 · 17 comments
Labels
feature a feature request or enhancement idea
Milestone

Comments

@gaborcsardi
Copy link
Member

Would be nice.

@krlmlr
Copy link
Member

krlmlr commented Jun 13, 2017

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.

@gaborcsardi
Copy link
Member Author

That's not bad. But I also want it to work the same way. I.e.

  • turning on/off using the DEBUGME environment variable
  • printing messages in color

@krlmlr
Copy link
Member

krlmlr commented Jun 13, 2017

Want to spend a couple of hours in Brussels integrating these two packages?

@gaborcsardi
Copy link
Member Author

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?

@krlmlr
Copy link
Member

krlmlr commented Dec 3, 2017

plogr calls currently look like LOG_VERBOSE << expression;, so we'd need a whole new API for this, maybe printf-based?

@gaborcsardi
Copy link
Member Author

Yeah, vsnprintf I guess.

@gaborcsardi
Copy link
Member Author

And we would also need to embed the C lib into debugme or plogr...

@krlmlr
Copy link
Member

krlmlr commented Dec 3, 2017

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?

@gaborcsardi
Copy link
Member Author

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.

@krlmlr
Copy link
Member

krlmlr commented Dec 3, 2017

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.

@gaborcsardi
Copy link
Member Author

OTOH, it would be just easier to use sg like https://github.com/wonder-mice/zf_log

@krlmlr
Copy link
Member

krlmlr commented Dec 3, 2017

Yeah, I'd suggest to use a header-only library, though.

@gaborcsardi
Copy link
Member Author

I am not sure if there is a header only C logging library.

@krlmlr
Copy link
Member

krlmlr commented Dec 3, 2017

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?

@gaborcsardi
Copy link
Member Author

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.

@krlmlr
Copy link
Member

krlmlr commented Dec 3, 2017

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?

@gaborcsardi
Copy link
Member Author

Yes, sure, those must be macros.

@gaborcsardi gaborcsardi added this to the V2 milestone Apr 23, 2018
@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement idea
Projects
None yet
Development

No branches or pull requests

2 participants