diff --git a/CHANGELOG.md b/CHANGELOG.md index 10bf4a1..df432be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Procedure when bumping the version number: ### Changed - Respect colon-delimited emoji when calculating nick hue - Display colon-delimited emoji in nicks and messages +- Non-export info is now printed to stderr instead of stdout ### Fixed - Mentions not being stopped by `>` diff --git a/src/config.rs b/src/config.rs index c6c98b5..2a8d13f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -49,7 +49,7 @@ impl Config { match toml::from_str(&content) { Ok(config) => config, Err(err) => { - println!("Error loading config file: {err}"); + eprintln!("Error loading config file: {err}"); Self::default() } } diff --git a/src/export/json.rs b/src/export/json.rs index 6fb3d13..8921229 100644 --- a/src/export/json.rs +++ b/src/export/json.rs @@ -28,13 +28,13 @@ pub async fn export(vault: &EuphRoomVault, file: &mut W) -> anyhow::Re } if total % 100000 == 0 { - println!(" {total} messages"); + eprintln!(" {total} messages"); } } write!(file, "\n]")?; - println!(" {total} messages in total"); + eprintln!(" {total} messages in total"); Ok(()) } @@ -56,10 +56,10 @@ pub async fn export_stream(vault: &EuphRoomVault, file: &mut W) -> any } if total % 100000 == 0 { - println!(" {total} messages"); + eprintln!(" {total} messages"); } } - println!(" {total} messages in total"); + eprintln!(" {total} messages in total"); Ok(()) } diff --git a/src/export/text.rs b/src/export/text.rs index 9dd7c6b..0cdd138 100644 --- a/src/export/text.rs +++ b/src/export/text.rs @@ -26,10 +26,10 @@ pub async fn export(vault: &EuphRoomVault, out: &mut W) -> anyhow::Res exported_msgs += tree.len(); if exported_trees % 10000 == 0 { - println!(" {exported_trees} trees, {exported_msgs} messages") + eprintln!(" {exported_trees} trees, {exported_msgs} messages") } } - println!(" {exported_trees} trees, {exported_msgs} messages in total"); + eprintln!(" {exported_trees} trees, {exported_msgs} messages in total"); Ok(()) } diff --git a/src/main.rs b/src/main.rs index 4fb274c..d2886db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -125,7 +125,7 @@ async fn main() -> anyhow::Result<()> { let config_path = args .config .unwrap_or_else(|| dirs.config_dir().join("config.toml")); - println!("Config file: {}", config_path.to_string_lossy()); + eprintln!("Config file: {}", config_path.to_string_lossy()); let mut config = Config::load(&config_path); set_data_dir(&mut config, args.data_dir); set_ephemeral(&mut config, args.ephemeral); @@ -139,7 +139,7 @@ async fn main() -> anyhow::Result<()> { .data_dir .clone() .unwrap_or_else(|| dirs.data_dir().to_path_buf()); - println!("Data dir: {}", data_dir.to_string_lossy()); + eprintln!("Data dir: {}", data_dir.to_string_lossy()); vault::launch(&data_dir.join("vault.db"))? }; @@ -147,12 +147,12 @@ async fn main() -> anyhow::Result<()> { Command::Run => run(logger, logger_rx, config, &vault, args.measure_widths).await?, Command::Export(args) => export::export(&vault.euph(), args).await?, Command::Gc => { - println!("Cleaning up and compacting vault"); - println!("This may take a while..."); + eprintln!("Cleaning up and compacting vault"); + eprintln!("This may take a while..."); vault.gc().await; } Command::ClearCookies => { - println!("Clearing cookies"); + eprintln!("Clearing cookies"); vault.euph().set_cookies(CookieJar::new()); } } @@ -164,7 +164,7 @@ async fn main() -> anyhow::Result<()> { // this, it is not implemented via a normal function call. drop(logger_guard); - println!("Goodbye!"); + eprintln!("Goodbye!"); Ok(()) } diff --git a/src/vault.rs b/src/vault.rs index a490154..9352e7d 100644 --- a/src/vault.rs +++ b/src/vault.rs @@ -50,7 +50,7 @@ fn run(mut conn: Connection, mut rx: mpsc::UnboundedReceiver) { while let Some(request) = rx.blocking_recv() { match request { Request::Close(tx) => { - println!("Closing vault"); + eprintln!("Closing vault"); if let Err(e) = conn.execute_batch("PRAGMA optimize") { error!("{e}"); } @@ -79,7 +79,7 @@ fn launch_from_connection(mut conn: Connection, ephemeral: bool) -> rusqlite::Re conn.pragma_update(None, "foreign_keys", true)?; conn.pragma_update(None, "trusted_schema", false)?; - println!("Opening vault"); + eprintln!("Opening vault"); migrate::migrate(&mut conn)?; prepare::prepare(&mut conn)?; diff --git a/src/vault/migrate.rs b/src/vault/migrate.rs index cbb4f6b..8cd42c6 100644 --- a/src/vault/migrate.rs +++ b/src/vault/migrate.rs @@ -9,7 +9,7 @@ pub fn migrate(conn: &mut Connection) -> rusqlite::Result<()> { let total = MIGRATIONS.len(); assert!(user_version <= total, "malformed database schema"); for (i, migration) in MIGRATIONS.iter().enumerate().skip(user_version) { - println!("Migrating vault from {} to {} (out of {})", i, i + 1, total); + eprintln!("Migrating vault from {} to {} (out of {})", i, i + 1, total); migration(&mut tx)?; }