gtk-rs / glib

DEPRECATED, use https://github.com/gtk-rs/gtk-rs-core repository instead!
http://gtk-rs.org/
MIT License
93 stars 62 forks source link

Added register_glib_to_logcrate_logger function to do glib-to-rust logging #699

Closed xanathar closed 4 years ago

xanathar commented 4 years ago

This adds a new register_glib_to_logcrate_logger function which routes all logging happening into glib to the log crate commonly used in Rust.

This is basically the reverse of GlibLogger (which routes the log crate to glib).

I found no trivial way (due to the fact that GlibLogger has a const fn constructor to simplify integration etc.) to prevent the user to use both GlibLogger and register_glib_to_logcrate_logger at the same time, which causes an obvious stack overflow (luckily, very early in the application lifetime).

I clarified the potential stack overflow in the documentation. If preferred, different cargo features can be used to "xor" the two functionalities; I felt that to be more complicated than the problem it solved but it's personal opinion :)

Related issue: https://github.com/gtk-rs/glib/issues/658

xanathar commented 4 years ago

PR is (in theory) ready.

CI fails (on Rust stable targets) with this:

git diff -R --exit-code
diff --git b/src/auto/versions.txt a/src/auto/versions.txt
index ff9347c..0f6b6a9 100644
--- b/src/auto/versions.txt
+++ a/src/auto/versions.txt
@@ -1,2 +1,2 @@
-Generated by gir (https://github.com/gtk-rs/gir @ ad40c01)
+Generated by gir (https://github.com/gtk-rs/gir @ ad40c01+)
 from gir-files (https://github.com/gtk-rs/gir-files @ 9f47916)
make: *** [regen_check] Error 1
The command "if [ "$TRAVIS_RUST_VERSION" == "stable" ] && ! [ "$ARM" == "1" ]; then rustup component add rustfmt; make regen_check; fi" exited with 2.

Not really sure if it's a problem of the commit (can't see why) or with CI itself.

sdroege commented 4 years ago

Not really sure if it's a problem of the commit (can't see why) or with CI itself.

Problem with the CI, don't worry about that :)

sdroege commented 4 years ago

Thanks, looks good :)