Skip to content

Conversation

swsnr
Copy link
Contributor

@swsnr swsnr commented Oct 13, 2024

Fixes #1538

@swsnr
Copy link
Contributor Author

swsnr commented Oct 13, 2024

Tested with the following example:

const G_LOG_DOMAIN: &str = "LOGTEST";

fn main() {
    static GLIB_LOGGER: glib::GlibLogger = glib::GlibLogger::new(
        glib::GlibLoggerFormat::Structured,
        glib::GlibLoggerDomain::CrateTarget,
    );
    rs_log::set_logger(&GLIB_LOGGER).unwrap();
    rs_log::set_max_level(rs_log::LevelFilter::Debug);

    glib::debug!("DEBUG");
    glib::info!("INFO");
    glib::warn!("WARN");
}

With this PR G_MESSAGES_DEBUG shows all messages:

$ G_MESSAGES_DEBUG=LOGTEST cargo run --features log,log_macros --package glib --example logtest
   Compiling glib v0.21.0 (/home/basti/Code/gtk-rs/gtk-rs-core/glib)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.40s
     Running `target/debug/examples/logtest`
(process:66204): LOGTEST-DEBUG: 09:36:13.777: DEBUG
LOGTEST-INFO: 09:36:13.777: INFO

(process:66204): LOGTEST-WARNING **: 09:36:13.777: WARN

Previously, it'd only show the warning message.

If it's any help I can also include the example in the pull request.

@sdroege
Copy link
Member

sdroege commented Oct 14, 2024

As mentioned in #1538 (comment) this is not the way to go. It would incur an unnecessary performance penalty and shouldn't be necessary

@sdroege sdroege closed this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Structured logging must pass GLIB_DOMAIN as nul-terminated string

2 participants