softprops / json-env-logger

A structured JSON logger for Rust.
MIT License
30 stars 13 forks source link

the trait `ToValue` is not implemented for `std::string::String` #6

Open acim opened 3 years ago

acim commented 3 years ago

After upgrading log to 0.4.14, json_env_logger won't compile:

error[E0277]: the trait bound `std::string::String: ToValue` is not satisfied
  --> /home/acim/.cargo/registry/src/github.com-1ecc6299db9ec823/json_env_logger-0.1.1/src/lib.rs:79:21
   |
79 | /                     kv_log_macro::error!(
80 | |                         "panicked at '{}'", msg,
81 | |                         {
82 | |                             thread: thread,
83 | |                             location: format!("{}:{}", location.file(), location.line())
84 | |                         }
85 | |                     );
   | |______________________^ the trait `ToValue` is not implemented for `std::string::String`
   |
   = note: required for the cast to the object type `dyn ToValue`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `json_env_logger`
RicoGit commented 3 years ago

Yep, have the same error.

acim commented 3 years ago

If I pin log version, this works again:

log = ">=0.4.13, <0.4.14"

There is obviously some change in log 0.4.14 which breaks json-env-logger.

notmgsk commented 2 years ago

I had to follow the advice here and adjust features: https://github.com/http-rs/tide/pull/776

Lawliet-Chan commented 2 years ago

Now this bug appears again in log = "0.4.17"

4TT1L4 commented 2 years ago

I had to follow the advice here and adjust features: http-rs/tide#776

@notmgsk Thanks for the hint, this solved the issue for me.

After defining the kv_unstable_std for the log dependency, I could compile json_env_logger:

log = { version = "0.4.17", features = ["kv_unstable_std"] }
json_env_logger = { version = "0.1" }
griffobeid commented 1 year ago

I put up a PR for this: https://github.com/softprops/json-env-logger/pull/14