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
Allow to configure a custom logging backend #134
Comments
Thanks for the submission @marcmo! I'm going to write down some notes and observations here :) Right now it seems that module "initialization" is somewhat static. We can see that the logging implementation is registered here in Probably something we can think about doing is adding some sort of hook where module authors can define their own initialization function and #[node_bindgen(init)]
fn init_my_module() {
// Logging init or other global setup
} Implementation-wise, I'm imagining that we could probably use some sort of static that holds a reference to a |
Hi @nicholastmosher, thanks for laying out your thoughts on this. |
I think when I suggested that solution, I was looking at some code from tracing as inspiration: https://github.com/tokio-rs/tracing/blob/master/tracing-core/src/dispatch.rs#L197-L202 They have a static GLOBAL_DISPATCH, where "dispatch" seems to refer to a reference to a particular "Collector", which is their interface for receiving log events. I will need to come back and read that more thoroughly, but I wanted to post it in case it can help you think through what an implementation here might look like |
Hi, I also would like to setup a custom logger. The problem is that the
And then just call |
Thanks for suggestion. Will try to address this issue soon. |
@Badel2 What option do you need for init? It's hard to pass argument. It would be simpler if pick up form env variable. If we go with |
Actually I need to pass a function, like this: let rust_addon = require("../../rust-dist");
rust_addon.manual_init(function(msg) {
console.log(msg);
}); I tried to get a reference to Another possibility is to allow using node-bindgen/nj-core/src/lib.rs Lines 124 to 126 in 6450525
Into something like if std::env("RUST_LOG") == "off" {
// Do not initialize logger here, to allow user to set a custom logger
} else {
fluvio_future::subscriber::init_logger();
} |
- fixes infinyon#134 - Provide macro to run code on initialization without introducing additional direct dependencies to client projects. - without this global initialization applications need to setup their own logging infrastructure at startup - Adapted function example with the use of a custom logger
- fixes infinyon#134 - Provide macro to run code on initialization without introducing additional direct dependencies to client projects. - without this global initialization applications need to setup their own logging infrastructure at startup - Adapted logger example with the use of a custom logger
Thanks to @marcmo, this issue is resolved. Should do release? I think only minor bump version is necessary |
It's currently not possible to configure a custom logging backend. What is needed is a way to use a custom logger along with some guidance of where to initialize it (since we do not have a
main
where this is done for applications.The text was updated successfully, but these errors were encountered: