slog-rs / slog

Structured, contextual, extensible, composable logging for Rust
https://slog.rs/
Apache License 2.0
1.58k stars 95 forks source link

bug report: slog-stdlog depends log::__private_api_log and slog-stdlog break with log v0.4.15 #309

Closed Sherlock-Holo closed 2 years ago

Sherlock-Holo commented 2 years ago

when updating log to 0.4.15, the log::__private_api_log change and slog-stdlog is broken

error[E0061]: this function takes 4 arguments but 3 arguments were supplied
    --> /home/sherlock/.cargo/registry/src/github.com-1ecc6299db9ec823/slog-stdlog-4.1.0/lib.rs:244:9
     |
244  |         log::__private_api_log(format_args!("{}", lazy), level, &(target, info.module(), info.file(), info.line()));
     |         ^^^^^^^^^^^^^^^^^^^^^^ ------------------------  -----  -------------------------------------------------- supplied 3 arguments
     |         |
     |         expected 4 arguments
     |
note: function defined here
    --> /home/sherlock/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.15/src/lib.rs:1576:8
     |
1576 | pub fn __private_api_log(
     |        ^^^^^^^^^^^^^^^^^

although this log::__private_api_log is exported, we all know this is a private function and hope no one uses it

could slog team bump a new version to fix it?

znation commented 2 years ago

+1 -- this seems to be blocking building of the slog-stdlog crate since it automatically picks up the newest log 0.4 package. Not sure how to fix this in a consumer of this crate since it doesn't seem possible to pin transitive dependency versions.

Drakulix commented 2 years ago

You can run cargo update -p log --precise 0.4.14 before building/checking/clippy/etc. But that should only be a temporary workaround.

clintfred commented 2 years ago

I have opened a PR in stdlog to lock to the revision. Hopefully it will get merged and released soon. https://github.com/slog-rs/stdlog/pull/20

JaimeValdemoros commented 2 years ago

It might be even simpler to remove the use of __private_api_log - it just calls through to logger().log(&Record::builder()...) which are now part of the public API: https://github.com/rust-lang/log/blob/21e30fc4f978e634c934d8136d024900bf707e29/src/lib.rs#L1573-L1598

(edit: seems https://github.com/rust-lang/log/issues/493 pretty much says the same thing)

Techcable commented 2 years ago

It might be even simpler to remove the use of __private_api_log - it just calls through to logger().log(&Record::builder()...) which are now part of the public API: https://github.com/rust-lang/log/blob/21e30fc4f978e634c934d8136d024900bf707e29/src/lib.rs#L1573-L1598

(edit: seems https://github.com/rust-lang/log/issues/493 pretty much says the same thing)

Yes I will look into this. We should definitely use a public API if at all possible!

Techcable commented 2 years ago

I just released slog-stdlog version 4.1.1 with a fix for this.

This avoids using the private API entirely (so it shouldn't break again in the future) :)