From 4c6a287f4d18161ed263bb37905edb2566f81245 Mon Sep 17 00:00:00 2001
From: Ellie Huxtable <ellie@elliehuxtable.com>
Date: Fri, 16 Dec 2022 18:37:45 +0000
Subject: [PATCH] Switch to using ATUIN_LOG instead of RUST_LOG (#642)

* Switch to using ATUIN_LOG instead of RUST_LOG

* Stop clippy complaining

* I should know better - clippy is never happy :(
---
 Cargo.lock                               | 184 ++++++++++++++++++-----
 Cargo.toml                               |   2 +-
 atuin-client/src/database.rs             |   2 +-
 src/command/client.rs                    |   6 +-
 src/command/client/history.rs            |   4 +-
 src/command/client/import.rs             |   2 +-
 src/command/client/search.rs             |   2 +-
 src/command/client/search/duration.rs    |   2 +-
 src/command/client/search/event.rs       |   2 +-
 src/command/client/search/interactive.rs |   2 +-
 src/command/client/sync.rs               |   2 +-
 src/command/client/sync/login.rs         |   2 +-
 src/command/contributors.rs              |   2 +-
 src/command/init.rs                      |   6 +-
 14 files changed, 167 insertions(+), 53 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index f43f0ad..ccc1a59 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -63,7 +63,7 @@ version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
  "winapi",
 ]
@@ -83,13 +83,13 @@ dependencies = [
  "cli-table",
  "crossbeam-channel",
  "directories",
+ "env_logger",
  "eyre",
  "fs-err",
  "indicatif",
  "interim",
  "itertools",
  "log",
- "pretty_env_logger",
  "rpassword",
  "semver",
  "serde",
@@ -561,17 +561,38 @@ dependencies = [
 
 [[package]]
 name = "env_logger"
-version = "0.7.1"
+version = "0.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
+checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
 dependencies = [
- "atty",
  "humantime",
+ "is-terminal",
  "log",
  "regex",
  "termcolor",
 ]
 
+[[package]]
+name = "errno"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
+dependencies = [
+ "errno-dragonfly",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "errno-dragonfly"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
+dependencies = [
+ "cc",
+ "libc",
+]
+
 [[package]]
 name = "event-listener"
 version = "2.5.3"
@@ -761,6 +782,15 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "hermit-abi"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
+dependencies = [
+ "libc",
+]
+
 [[package]]
 name = "hex"
 version = "0.4.3"
@@ -827,12 +857,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
 
 [[package]]
 name = "humantime"
-version = "1.3.0"
+version = "2.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
-dependencies = [
- "quick-error",
-]
+checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
 
 [[package]]
 name = "hyper"
@@ -941,12 +968,34 @@ dependencies = [
  "logos",
 ]
 
+[[package]]
+name = "io-lifetimes"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c"
+dependencies = [
+ "libc",
+ "windows-sys 0.42.0",
+]
+
 [[package]]
 name = "ipnet"
 version = "2.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b"
 
+[[package]]
+name = "is-terminal"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330"
+dependencies = [
+ "hermit-abi 0.2.6",
+ "io-lifetimes",
+ "rustix",
+ "windows-sys 0.42.0",
+]
+
 [[package]]
 name = "itertools"
 version = "0.10.5"
@@ -979,9 +1028,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.132"
+version = "0.2.138"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
+checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
 
 [[package]]
 name = "libsodium-sys"
@@ -1006,6 +1055,12 @@ dependencies = [
  "vcpkg",
 ]
 
+[[package]]
+name = "linux-raw-sys"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
+
 [[package]]
 name = "lock_api"
 version = "0.4.8"
@@ -1105,7 +1160,7 @@ dependencies = [
  "libc",
  "log",
  "wasi 0.11.0+wasi-snapshot-preview1",
- "windows-sys",
+ "windows-sys 0.36.1",
 ]
 
 [[package]]
@@ -1211,7 +1266,7 @@ version = "1.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
 ]
 
@@ -1296,7 +1351,7 @@ dependencies = [
  "libc",
  "redox_syscall",
  "smallvec",
- "windows-sys",
+ "windows-sys 0.36.1",
 ]
 
 [[package]]
@@ -1372,16 +1427,6 @@ version = "0.2.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
 
-[[package]]
-name = "pretty_env_logger"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d"
-dependencies = [
- "env_logger",
- "log",
-]
-
 [[package]]
 name = "proc-macro-error"
 version = "1.0.4"
@@ -1415,12 +1460,6 @@ dependencies = [
  "unicode-ident",
 ]
 
-[[package]]
-name = "quick-error"
-version = "1.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
-
 [[package]]
 name = "quote"
 version = "1.0.21"
@@ -1601,6 +1640,20 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "rustix"
+version = "0.36.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588"
+dependencies = [
+ "bitflags",
+ "errno",
+ "io-lifetimes",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.42.0",
+]
+
 [[package]]
 name = "rustls"
 version = "0.20.6"
@@ -1656,7 +1709,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2"
 dependencies = [
  "lazy_static",
- "windows-sys",
+ "windows-sys 0.36.1",
 ]
 
 [[package]]
@@ -2554,43 +2607,100 @@ version = "0.36.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
 dependencies = [
- "windows_aarch64_msvc",
- "windows_i686_gnu",
- "windows_i686_msvc",
- "windows_x86_64_gnu",
- "windows_x86_64_msvc",
+ "windows_aarch64_msvc 0.36.1",
+ "windows_i686_gnu 0.36.1",
+ "windows_i686_msvc 0.36.1",
+ "windows_x86_64_gnu 0.36.1",
+ "windows_x86_64_msvc 0.36.1",
 ]
 
+[[package]]
+name = "windows-sys"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc 0.42.0",
+ "windows_i686_gnu 0.42.0",
+ "windows_i686_msvc 0.42.0",
+ "windows_x86_64_gnu 0.42.0",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc 0.42.0",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
+
 [[package]]
 name = "windows_aarch64_msvc"
 version = "0.36.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
 
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
+
 [[package]]
 name = "windows_i686_gnu"
 version = "0.36.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
 
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
+
 [[package]]
 name = "windows_i686_msvc"
 version = "0.36.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
 
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
+
 [[package]]
 name = "windows_x86_64_gnu"
 version = "0.36.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
 
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
+
 [[package]]
 name = "windows_x86_64_msvc"
 version = "0.36.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
 
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
+
 [[package]]
 name = "winreg"
 version = "0.10.1"
diff --git a/Cargo.toml b/Cargo.toml
index 52c1449..062a4f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -49,7 +49,7 @@ atuin-client = { path = "atuin-client", version = "12.0.0", optional = true, def
 atuin-common = { path = "atuin-common", version = "12.0.0" }
 
 log = "0.4"
-pretty_env_logger = "0.4"
+env_logger = "0.10.0"
 chrono = { version = "0.4", features = ["serde"] }
 eyre = "0.6"
 directories = "4"
diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs
index b0d05db..e1b58e0 100644
--- a/atuin-client/src/database.rs
+++ b/atuin-client/src/database.rs
@@ -738,7 +738,7 @@ impl SqlBuilderExt for SqlBuilder {
         } else {
             cond.push_str(" LIKE '");
         }
-        cond.push_str(&esc(&mask.to_string()));
+        cond.push_str(&esc(mask.to_string()));
         cond.push('\'');
         if is_or {
             self.or_where(cond)
diff --git a/src/command/client.rs b/src/command/client.rs
index f7b9d6f..df74ac5 100644
--- a/src/command/client.rs
+++ b/src/command/client.rs
@@ -4,6 +4,7 @@ use clap::Subcommand;
 use eyre::{Result, WrapErr};
 
 use atuin_client::{database::Sqlite, settings::Settings};
+use env_logger::Builder;
 
 #[cfg(feature = "sync")]
 mod sync;
@@ -38,7 +39,10 @@ pub enum Cmd {
 impl Cmd {
     #[tokio::main(flavor = "current_thread")]
     pub async fn run(self) -> Result<()> {
-        pretty_env_logger::init();
+        Builder::new()
+            .filter_level(log::LevelFilter::Off)
+            .parse_env("ATUIN_LOG")
+            .init();
 
         let settings = Settings::new().wrap_err("could not load client settings")?;
 
diff --git a/src/command/client/history.rs b/src/command/client/history.rs
index 5c3f172..19a3df0 100644
--- a/src/command/client/history.rs
+++ b/src/command/client/history.rs
@@ -202,11 +202,11 @@ impl Cmd {
                 let history = match (session, cwd) {
                     (None, None) => db.list(settings.filter_mode, &context, None, false).await?,
                     (None, Some(cwd)) => {
-                        let query = format!("select * from history where cwd = '{}';", cwd);
+                        let query = format!("select * from history where cwd = '{cwd}';");
                         db.query_history(&query).await?
                     }
                     (Some(session), None) => {
-                        let query = format!("select * from history where session = '{}';", session);
+                        let query = format!("select * from history where session = '{session}';");
                         db.query_history(&query).await?
                     }
                     (Some(session), Some(cwd)) => {
diff --git a/src/command/client/import.rs b/src/command/client/import.rs
index b0375ac..f14598f 100644
--- a/src/command/client/import.rs
+++ b/src/command/client/import.rs
@@ -64,7 +64,7 @@ impl Cmd {
                     println!("Detected Bash");
                     import::<Bash, DB>(db).await
                 } else {
-                    println!("cannot import {} history", shell);
+                    println!("cannot import {shell} history");
                     Ok(())
                 }
             }
diff --git a/src/command/client/search.rs b/src/command/client/search.rs
index b87b86c..456846d 100644
--- a/src/command/client/search.rs
+++ b/src/command/client/search.rs
@@ -64,7 +64,7 @@ impl Cmd {
     pub async fn run(self, db: &mut impl Database, settings: &Settings) -> Result<()> {
         if self.interactive {
             let item = interactive::history(&self.query, settings, db).await?;
-            eprintln!("{}", item);
+            eprintln!("{item}");
         } else {
             let list_mode = ListMode::from_flags(self.human, self.cmd_only);
             let entries = run_non_interactive(
diff --git a/src/command/client/search/duration.rs b/src/command/client/search/duration.rs
index 3cdd4e8..1dc4245 100644
--- a/src/command/client/search/duration.rs
+++ b/src/command/client/search/duration.rs
@@ -4,7 +4,7 @@ use std::{ops::ControlFlow, time::Duration};
 pub fn format_duration(f: Duration) -> String {
     fn item(name: &str, value: u64) -> ControlFlow<String> {
         if value > 0 {
-            ControlFlow::Break(format!("{}{}", value, name))
+            ControlFlow::Break(format!("{value}{name}"))
         } else {
             ControlFlow::Continue(())
         }
diff --git a/src/command/client/search/event.rs b/src/command/client/search/event.rs
index 8044e27..0e791c9 100644
--- a/src/command/client/search/event.rs
+++ b/src/command/client/search/event.rs
@@ -43,7 +43,7 @@ impl Events {
                 let tty = termion::get_tty().expect("Could not find tty");
                 for event in tty.events().flatten() {
                     if let Err(err) = tx.send(Event::Input(event)) {
-                        eprintln!("{}", err);
+                        eprintln!("{err}");
                         return;
                     }
                 }
diff --git a/src/command/client/search/interactive.rs b/src/command/client/search/interactive.rs
index e23b7c6..2bc07da 100644
--- a/src/command/client/search/interactive.rs
+++ b/src/command/client/search/interactive.rs
@@ -256,7 +256,7 @@ impl State {
             .split(chunks[0]);
 
         let title = Paragraph::new(Text::from(Span::styled(
-            format!("Atuin v{}", VERSION),
+            format!("Atuin v{VERSION}"),
             Style::default().fg(Color::DarkGray),
         )));
 
diff --git a/src/command/client/sync.rs b/src/command/client/sync.rs
index 51fcbf6..b97a224 100644
--- a/src/command/client/sync.rs
+++ b/src/command/client/sync.rs
@@ -41,7 +41,7 @@ impl Cmd {
                 use atuin_client::encryption::{encode_key, load_key};
                 let key = load_key(&settings).wrap_err("could not load encryption key")?;
                 let encode = encode_key(key).wrap_err("could not encode encryption key")?;
-                println!("{}", encode);
+                println!("{encode}");
                 Ok(())
             }
         }
diff --git a/src/command/client/sync/login.rs b/src/command/client/sync/login.rs
index 333a151..038e822 100644
--- a/src/command/client/sync/login.rs
+++ b/src/command/client/sync/login.rs
@@ -72,6 +72,6 @@ pub(super) fn read_user_password() -> String {
 }
 
 fn read_user_input(name: &'static str) -> String {
-    eprint!("Please enter {}: ", name);
+    eprint!("Please enter {name}: ");
     get_input().expect("Failed to read from input")
 }
diff --git a/src/command/contributors.rs b/src/command/contributors.rs
index 774136c..060af8f 100644
--- a/src/command/contributors.rs
+++ b/src/command/contributors.rs
@@ -61,5 +61,5 @@ ZhiHong Li (@OnePieceJoker)
 "#;
 
 pub fn run() {
-    println!("{}", CONTRIBUTORS);
+    println!("{CONTRIBUTORS}");
 }
diff --git a/src/command/init.rs b/src/command/init.rs
index 37453f9..7faff03 100644
--- a/src/command/init.rs
+++ b/src/command/init.rs
@@ -12,17 +12,17 @@ pub enum Cmd {
 
 fn init_zsh() {
     let full = include_str!("../shell/atuin.zsh");
-    println!("{}", full);
+    println!("{full}");
 }
 
 fn init_bash() {
     let full = include_str!("../shell/atuin.bash");
-    println!("{}", full);
+    println!("{full}");
 }
 
 fn init_fish() {
     let full = include_str!("../shell/atuin.fish");
-    println!("{}", full);
+    println!("{full}");
 }
 
 impl Cmd {