mrkmarron / logpp

An experimental next generation logging framework for JavaScript and fluent.
MIT License
65 stars 0 forks source link

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

Open jhecking opened 5 years ago

jhecking commented 5 years ago

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.

mrkmarron commented 5 years ago

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.

jhecking commented 5 years ago

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?

mrkmarron commented 5 years ago

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.