logpp icon indicating copy to clipboard operation
logpp copied to clipboard

Question: Native API for Logging in other Native Add-ons

Open jhecking opened this issue 6 years ago • 3 comments

Does Log++ provide a native (i.e. C/C++) API in addition to the JS API for applications to use for logging? Or would it be feasible to add such an API? I'm asking because I am maintaining a Node.js module which has a native add-on, and I have not yet been able to find a logging framework that would allow me to generate log messages both from the JS as well as the C++ parts of the module and write them to a single log stream, with a single set of logging formats, levels, etc. I was hopeful when I saw that Log++ actually does the logging in a native add-on, but it seems there is no native API exposed.

jhecking avatar Jul 20 '18 02:07 jhecking

Unfortunately you are correct. Log++ does not yet provide an API for logging from another native (C/C++) component. The challenge is that we buffer log messages on the managed side and upcalls from C++ into JS can be expensive.

It would be great if we can find a low-cost & VM neutral way to provide both JS and native logging but we may end up needing some specialized support from the JS engines to make things fast enough.

mrkmarron avatar Jul 21 '18 04:07 mrkmarron

I saw the JS buffer logic after filing the issue. Am I correct, that moving the buffer into the native component is also not an option because that would require a JS -> C++ call for every logging statement and the overhead for that would just be too high?

jhecking avatar Jul 24 '18 08:07 jhecking

Hi, yes that is correct. The standard binding mechanism results in a fair bit of cost for JS->C++ transition and is higher than I was happy with. There is a possibility of adding some runtime optimized bindings to the VM but I haven't made progress on that yet.

mrkmarron avatar Aug 13 '18 20:08 mrkmarron