-
-
Notifications
You must be signed in to change notification settings - Fork 62
Support for logging through the log crate #658
Comments
I think having integration into the log crate into both directions would be useful to have in the glib bindings ( |
Cool thanks, I'll send a contribution as soon as I can. |
Now the only other thing that would be useful to have is a GLib logging function that directly calls into the |
I can do that, but it will take a little more time. |
No worries :) |
I've done this... but it's very very minimal: fn default_glib_log_handler(string1: &str, level: glib::LogLevel, string2: &str) {
let level = match level {
glib::LogLevel::Error | glib::LogLevel::Critical => log::Level::Error,
glib::LogLevel::Warning => log::Level::Warn,
glib::LogLevel::Message | glib::LogLevel::Info => log::Level::Info,
glib::LogLevel::Debug => log::Level::Debug,
};
log!(target: string1, level, "{}", string2);
}
fn main() {
glib::log_set_default_handler(default_glib_log_handler);
...
} I don't even know if it's worth adding to the glib-rs library, given that it's such small snippet (though I can easily send a PR for that). Did you have in mind something with a bigger scope? |
No, exactly that. It's not very complicated but it's boring to copy such a thing from project to project :) |
Ok, I'll send a PR very soon, then :) |
Hi,
searching for a solution to integrate a Rust project with glib logging, I stumbled on the glib_logger project, which bridges glib logging with the log crate.
Since it didn't have full support for domains and other features I was interested in, I sent a PR (still pending) which adds the missing bits.
However, I was wondering if there is an interest in adopting such a solution in the main gtk-rs sources, given that logging is quite a basic functionality which pretty much all glib applications need, and that this is a fair solution at being as idiomatic as possible while still integrating with glib log handlers.
Would a PR for this be welcome (in which project) or not?
Or, in general, your thoughts?
The text was updated successfully, but these errors were encountered: