From 0da60556534d37f7141b0e242af4005108d62751 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 10 Feb 2025 11:30:02 +1100 Subject: [PATCH 1/6] Update env_logger from 0.6 to 0.11.x --- Cargo.lock | 77 ++++++++++++++++++---------------- graphql_client_cli/src/main.rs | 77 ++++++++++++++++++++++++---------- 2 files changed, 97 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ad213d8..461021eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -293,7 +293,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -311,6 +311,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" version = "0.5.13" @@ -318,7 +328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" dependencies = [ "atty", - "humantime", + "humantime 1.3.0", "log", "regex", "termcolor", @@ -326,15 +336,15 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.6.2" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ - "atty", - "humantime", + "anstream", + "anstyle", + "env_filter", + "humantime 2.1.0", "log", - "regex", - "termcolor", ] [[package]] @@ -502,14 +512,14 @@ name = "graphql_client_cli" version = "0.14.0" dependencies = [ "clap", - "env_logger 0.6.2", + "env_logger 0.11.6", "graphql_client", "graphql_client_codegen", "log", "reqwest", "serde", "serde_json", - "syn 1.0.109", + "syn", ] [[package]] @@ -524,7 +534,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 1.0.109", + "syn", ] [[package]] @@ -533,7 +543,7 @@ version = "0.14.0" dependencies = [ "graphql_client_codegen", "proc-macro2", - "syn 1.0.109", + "syn", ] [[package]] @@ -657,6 +667,12 @@ dependencies = [ "quick-error", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "1.6.0" @@ -845,7 +861,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -1045,7 +1061,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -1453,7 +1469,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -1535,17 +1551,6 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.98" @@ -1574,7 +1579,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -1658,7 +1663,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -1669,7 +1674,7 @@ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -1896,7 +1901,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.98", + "syn", "wasm-bindgen-shared", ] @@ -1931,7 +1936,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2171,7 +2176,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", "synstructure", ] @@ -2193,7 +2198,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -2213,7 +2218,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", "synstructure", ] @@ -2242,5 +2247,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] diff --git a/graphql_client_cli/src/main.rs b/graphql_client_cli/src/main.rs index 94a3fc0d..a5386d34 100644 --- a/graphql_client_cli/src/main.rs +++ b/graphql_client_cli/src/main.rs @@ -4,9 +4,11 @@ mod introspection_queries; mod introspection_schema; use clap::Parser; -use env_logger::fmt::{Color, Style, StyledValue}; -use error::Error; +use env_logger::fmt::style; use log::Level; + +use error::Error; + use std::path::PathBuf; use Cli::Generate; @@ -151,33 +153,66 @@ fn set_env_logger() { use std::io::Write; env_logger::Builder::from_default_env() - .format(|f, record| { - let mut style = f.style(); - let level = colored_level(&mut style, record.level()); - let mut style = f.style(); - let file = style.set_bold(true).value("file"); - let mut style = f.style(); - let module = style.set_bold(true).value("module"); + .format(|f, record | { + let level_style = colored_level(record.level()); + let file_style = style::Style::new().bold(); + let module_style = style::Style::new().bold(); writeln!( f, - "{} {}: {} {}: {}\n{}", - level, - file, + "{level_style}{}{level_style:#} {file_style}file{file_style:#}: {} {module_style}module{module_style:#}: {}\n{}", + record.level(), record.file().unwrap(), - module, record.target(), record.args() ) - }) - .init(); + }).init(); } -fn colored_level(style: &mut Style, level: Level) -> StyledValue<'_, &'static str> { +fn colored_level(level: Level) -> style::Style { match level { - Level::Trace => style.set_color(Color::Magenta).value("TRACE"), - Level::Debug => style.set_color(Color::Blue).value("DEBUG"), - Level::Info => style.set_color(Color::Green).value("INFO "), - Level::Warn => style.set_color(Color::Yellow).value("WARN "), - Level::Error => style.set_color(Color::Red).value("ERROR"), + Level::Trace => style::Style::new().fg_color(Some(style::AnsiColor::Magenta.into())), + Level::Debug => style::Style::new().fg_color(Some(style::AnsiColor::Blue.into())), + Level::Info => style::Style::new().fg_color(Some(style::AnsiColor::Green.into())), + Level::Warn => style::Style::new().fg_color(Some(style::AnsiColor::Yellow.into())), + Level::Error => style::Style::new().fg_color(Some(style::AnsiColor::Red.into())), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use log::trace; + use std::env; + + #[test] + fn test_colored_level() { + assert_eq!( + colored_level(Level::Trace), + style::Style::new().fg_color(Some(style::AnsiColor::Magenta.into())) + ); + assert_eq!( + colored_level(Level::Debug), + style::Style::new().fg_color(Some(style::AnsiColor::Blue.into())) + ); + assert_eq!( + colored_level(Level::Info), + style::Style::new().fg_color(Some(style::AnsiColor::Green.into())) + ); + assert_eq!( + colored_level(Level::Warn), + style::Style::new().fg_color(Some(style::AnsiColor::Yellow.into())) + ); + assert_eq!( + colored_level(Level::Error), + style::Style::new().fg_color(Some(style::AnsiColor::Red.into())) + ); + } + + #[test] + #[ignore] + fn test_set_env_logger() { + env::set_var("RUST_LOG", "trace"); + set_env_logger(); + trace!("this is trace") } } From 129f5aecbbbb7b2e1e0a741fcc6fbabaa367e6a3 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 10 Feb 2025 11:32:24 +1100 Subject: [PATCH 2/6] Add Cargo.toml for updated dependency in previous commit --- graphql_client_cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql_client_cli/Cargo.toml b/graphql_client_cli/Cargo.toml index d583d654..e9abce94 100644 --- a/graphql_client_cli/Cargo.toml +++ b/graphql_client_cli/Cargo.toml @@ -19,7 +19,7 @@ clap = { version = "^4.0", features = ["derive"] } serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" log = "^0.4" -env_logger = "^0.6" +env_logger = { version = "0.11.6", features = ["color"] } syn = { version = "^2.0", features = ["full"] } [features] From 854db7db483ab38ef5b61e6ec8c80e7892839d0f Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 10 Feb 2025 11:42:19 +1100 Subject: [PATCH 3/6] update deps for example projects --- examples/github/Cargo.toml | 2 +- examples/hasura/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/github/Cargo.toml b/examples/github/Cargo.toml index f312779b..70c3f9c3 100644 --- a/examples/github/Cargo.toml +++ b/examples/github/Cargo.toml @@ -11,4 +11,4 @@ reqwest = { version = "0.12", features = ["json", "blocking"] } prettytable-rs = "^0.10.0" clap = { version = "^4.0", features = ["derive"] } log = "^0.4" -env_logger = "^0.5" +env_logger = "0.11.6" diff --git a/examples/hasura/Cargo.toml b/examples/hasura/Cargo.toml index b10df857..4b1b03f3 100644 --- a/examples/hasura/Cargo.toml +++ b/examples/hasura/Cargo.toml @@ -11,4 +11,4 @@ serde_json = "1.0" reqwest = { version = "0.12", features = ["json", "blocking"] } prettytable-rs = "0.10.0" log = "0.4.3" -env_logger = "0.5.10" +env_logger = "0.11.6" From bfeebb2eb2509f71cc82a9e8244f54106f5835f4 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 11 Feb 2025 08:34:13 +1100 Subject: [PATCH 4/6] revert env_logger to 0.10.2 due to MSRV check in env_logger setting minimum rust version to 1.71. This conflicts with graphql-client's minimum of 1.64 --- examples/github/Cargo.toml | 2 +- examples/hasura/Cargo.toml | 2 +- graphql_client_cli/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/github/Cargo.toml b/examples/github/Cargo.toml index 70c3f9c3..0a5d3636 100644 --- a/examples/github/Cargo.toml +++ b/examples/github/Cargo.toml @@ -11,4 +11,4 @@ reqwest = { version = "0.12", features = ["json", "blocking"] } prettytable-rs = "^0.10.0" clap = { version = "^4.0", features = ["derive"] } log = "^0.4" -env_logger = "0.11.6" +env_logger = "0.10.2" diff --git a/examples/hasura/Cargo.toml b/examples/hasura/Cargo.toml index 4b1b03f3..46d66a33 100644 --- a/examples/hasura/Cargo.toml +++ b/examples/hasura/Cargo.toml @@ -11,4 +11,4 @@ serde_json = "1.0" reqwest = { version = "0.12", features = ["json", "blocking"] } prettytable-rs = "0.10.0" log = "0.4.3" -env_logger = "0.11.6" +env_logger = "0.10.2" diff --git a/graphql_client_cli/Cargo.toml b/graphql_client_cli/Cargo.toml index e9abce94..2aebeb02 100644 --- a/graphql_client_cli/Cargo.toml +++ b/graphql_client_cli/Cargo.toml @@ -19,7 +19,7 @@ clap = { version = "^4.0", features = ["derive"] } serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" log = "^0.4" -env_logger = { version = "0.11.6", features = ["color"] } +env_logger = { version = "0.10.2", features = ["color"] } syn = { version = "^2.0", features = ["full"] } [features] From 5db67b97123829b8efcb4328bb87a1ba13ca76ba Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 11 Feb 2025 08:51:28 +1100 Subject: [PATCH 5/6] revert set_env_logger back to pre-0.11 for compatibility with rust 1.64 --- graphql_client_cli/Cargo.toml | 1 + graphql_client_cli/src/main.rs | 75 ++++++++++------------------------ 2 files changed, 22 insertions(+), 54 deletions(-) diff --git a/graphql_client_cli/Cargo.toml b/graphql_client_cli/Cargo.toml index 2aebeb02..924b374f 100644 --- a/graphql_client_cli/Cargo.toml +++ b/graphql_client_cli/Cargo.toml @@ -21,6 +21,7 @@ serde_json = "^1.0" log = "^0.4" env_logger = { version = "0.10.2", features = ["color"] } syn = { version = "^2.0", features = ["full"] } +anstyle = "1.0.10" [features] default = [] diff --git a/graphql_client_cli/src/main.rs b/graphql_client_cli/src/main.rs index a5386d34..5e7a111d 100644 --- a/graphql_client_cli/src/main.rs +++ b/graphql_client_cli/src/main.rs @@ -4,7 +4,7 @@ mod introspection_queries; mod introspection_schema; use clap::Parser; -use env_logger::fmt::style; +use env_logger::fmt::{Color, Style, StyledValue}; use log::Level; use error::Error; @@ -153,66 +153,33 @@ fn set_env_logger() { use std::io::Write; env_logger::Builder::from_default_env() - .format(|f, record | { - let level_style = colored_level(record.level()); - let file_style = style::Style::new().bold(); - let module_style = style::Style::new().bold(); + .format(|f, record| { + let mut style = f.style(); + let level = colored_level(&mut style, record.level()); + let mut style = f.style(); + let file = style.set_bold(true).value("file"); + let mut style = f.style(); + let module = style.set_bold(true).value("module"); writeln!( f, - "{level_style}{}{level_style:#} {file_style}file{file_style:#}: {} {module_style}module{module_style:#}: {}\n{}", - record.level(), + "{} {}: {} {}: {}\n{}", + level, + file, record.file().unwrap(), + module, record.target(), record.args() ) - }).init(); + }) + .init(); } -fn colored_level(level: Level) -> style::Style { +fn colored_level(style: &mut Style, level: Level) -> StyledValue<'_, &'static str> { match level { - Level::Trace => style::Style::new().fg_color(Some(style::AnsiColor::Magenta.into())), - Level::Debug => style::Style::new().fg_color(Some(style::AnsiColor::Blue.into())), - Level::Info => style::Style::new().fg_color(Some(style::AnsiColor::Green.into())), - Level::Warn => style::Style::new().fg_color(Some(style::AnsiColor::Yellow.into())), - Level::Error => style::Style::new().fg_color(Some(style::AnsiColor::Red.into())), + Level::Trace => style.set_color(Color::Magenta).value("TRACE"), + Level::Debug => style.set_color(Color::Blue).value("DEBUG"), + Level::Info => style.set_color(Color::Green).value("INFO "), + Level::Warn => style.set_color(Color::Yellow).value("WARN "), + Level::Error => style.set_color(Color::Red).value("ERROR"), } -} - -#[cfg(test)] -mod tests { - use super::*; - use log::trace; - use std::env; - - #[test] - fn test_colored_level() { - assert_eq!( - colored_level(Level::Trace), - style::Style::new().fg_color(Some(style::AnsiColor::Magenta.into())) - ); - assert_eq!( - colored_level(Level::Debug), - style::Style::new().fg_color(Some(style::AnsiColor::Blue.into())) - ); - assert_eq!( - colored_level(Level::Info), - style::Style::new().fg_color(Some(style::AnsiColor::Green.into())) - ); - assert_eq!( - colored_level(Level::Warn), - style::Style::new().fg_color(Some(style::AnsiColor::Yellow.into())) - ); - assert_eq!( - colored_level(Level::Error), - style::Style::new().fg_color(Some(style::AnsiColor::Red.into())) - ); - } - - #[test] - #[ignore] - fn test_set_env_logger() { - env::set_var("RUST_LOG", "trace"); - set_env_logger(); - trace!("this is trace") - } -} +} \ No newline at end of file From fbf164b7baaebfc43bd3a96e4bae1f0a356a0a80 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 11 Feb 2025 08:53:49 +1100 Subject: [PATCH 6/6] rust fmt -- --- graphql_client_cli/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql_client_cli/src/main.rs b/graphql_client_cli/src/main.rs index 5e7a111d..f7292935 100644 --- a/graphql_client_cli/src/main.rs +++ b/graphql_client_cli/src/main.rs @@ -182,4 +182,4 @@ fn colored_level(style: &mut Style, level: Level) -> StyledValue<'_, &'static st Level::Warn => style.set_color(Color::Yellow).value("WARN "), Level::Error => style.set_color(Color::Red).value("ERROR"), } -} \ No newline at end of file +}