Print non-export output on stderr

This commit is contained in:
Joscha 2023-02-12 00:55:44 +01:00
parent ca10ca277b
commit 84279d6800
7 changed files with 17 additions and 16 deletions

View file

@ -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 `>`

View file

@ -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()
}
}

View file

@ -28,13 +28,13 @@ pub async fn export<W: Write>(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<W: Write>(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(())
}

View file

@ -26,10 +26,10 @@ pub async fn export<W: Write>(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(())
}

View file

@ -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(())
}

View file

@ -50,7 +50,7 @@ fn run(mut conn: Connection, mut rx: mpsc::UnboundedReceiver<Request>) {
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)?;

View file

@ -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)?;
}