From b11eccec5bdc74426ce759634080e04d7d35db0f Mon Sep 17 00:00:00 2001 From: Arne Beer Date: Sat, 24 Aug 2024 14:07:57 +0200 Subject: [PATCH 1/2] change: Send all log output to stderr --- CHANGELOG.md | 2 ++ pueue/src/bin/pueue.rs | 14 ++++++++++++-- pueue/src/bin/pueued.rs | 14 ++++++++++++-- pueue/src/client/client.rs | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fcb738f..1c423e9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ TLDR: The new task state representation is more verbose but significantly cleane **Important: The Pueue daemon needs to be restarted and the state will be wiped clean.** - **Breaking**: Streamlined `pueue log` parameters to behave the same way as `start`, `pause` or `kill`. [#509](https://github.com/Nukesor/pueue/issues/509) - **Breaking**: Remove the `--children` commandline flags, that have been deprecated and no longer serve any function since `v3.0.0`. +- **Breaking**: Send log output to `stderr` instead of `stdout` [#562](https://github.com/Nukesor/pueue/issues/562). ### Add @@ -59,6 +60,7 @@ TLDR: The new task state representation is more verbose but significantly cleane - Fixed delay after sending process related commands from client. [#548](https://github.com/Nukesor/pueue/pull/548) - Callback templating arguments were html escaped by accident. [#564](https://github.com/Nukesor/pueue/pull/564) +- Print incompatible version warning info as a log message instead of plain stdout input, which broke json outputs [#562](https://github.com/Nukesor/pueue/issues/562). ## \[3.4.1\] - 2024-06-04 diff --git a/pueue/src/bin/pueue.rs b/pueue/src/bin/pueue.rs index ab4b9969..ab97f629 100644 --- a/pueue/src/bin/pueue.rs +++ b/pueue/src/bin/pueue.rs @@ -4,7 +4,7 @@ use anyhow::{bail, Context, Result}; use clap::{CommandFactory, Parser}; use clap_complete::{generate, generate_to, shells}; use log::warn; -use simplelog::{Config, ConfigBuilder, LevelFilter, SimpleLogger}; +use simplelog::{Config, ConfigBuilder, LevelFilter, SimpleLogger, TermLogger, TerminalMode}; use pueue_lib::settings::Settings; @@ -51,7 +51,17 @@ async fn main() -> Result<()> { Ok(builder) => builder.build(), }; - SimpleLogger::init(level, logger_config).unwrap(); + // Init a terminal logger. If this fails for some reason, try fallback to a SimpleLogger + if TermLogger::init( + level, + logger_config.clone(), + TerminalMode::Stderr, + simplelog::ColorChoice::Auto, + ) + .is_err() + { + SimpleLogger::init(level, logger_config).unwrap(); + } // Try to read settings from the configuration file. let (mut settings, config_found) = diff --git a/pueue/src/bin/pueued.rs b/pueue/src/bin/pueued.rs index 3313ccac..b637ba39 100644 --- a/pueue/src/bin/pueued.rs +++ b/pueue/src/bin/pueued.rs @@ -3,7 +3,7 @@ use std::process::Command; use anyhow::Result; use clap::Parser; use log::warn; -use simplelog::{Config, ConfigBuilder, LevelFilter, SimpleLogger}; +use simplelog::{Config, ConfigBuilder, LevelFilter, SimpleLogger, TermLogger, TerminalMode}; use pueue::daemon::cli::CliArguments; use pueue::daemon::run; @@ -35,7 +35,17 @@ async fn main() -> Result<()> { Ok(builder) => builder.build(), }; - SimpleLogger::init(level, logger_config).unwrap(); + // Init a terminal logger. If this fails for some reason, try fallback to a SimpleLogger + if TermLogger::init( + level, + logger_config.clone(), + TerminalMode::Stderr, + simplelog::ColorChoice::Auto, + ) + .is_err() + { + SimpleLogger::init(level, logger_config).unwrap(); + } run(opt.config, opt.profile, false).await } diff --git a/pueue/src/client/client.rs b/pueue/src/client/client.rs index cbbe54da..7dd145b6 100644 --- a/pueue/src/client/client.rs +++ b/pueue/src/client/client.rs @@ -110,7 +110,7 @@ impl Client { }; if show_warning { - println!( + error!( "Different daemon version detected '{version}'. Consider restarting the daemon." ); } From afa5b0af39eed507e118a39e547cf237c1302e2f Mon Sep 17 00:00:00 2001 From: Arne Beer Date: Sun, 25 Aug 2024 00:06:34 +0200 Subject: [PATCH 2/2] change: Default log level to warning --- CHANGELOG.md | 3 ++- pueue/src/bin/pueue.rs | 8 ++++---- pueue/src/bin/pueued.rs | 8 ++++---- pueue/src/client/client.rs | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c423e9e..e502c0e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,8 @@ TLDR: The new task state representation is more verbose but significantly cleane **Important: The Pueue daemon needs to be restarted and the state will be wiped clean.** - **Breaking**: Streamlined `pueue log` parameters to behave the same way as `start`, `pause` or `kill`. [#509](https://github.com/Nukesor/pueue/issues/509) - **Breaking**: Remove the `--children` commandline flags, that have been deprecated and no longer serve any function since `v3.0.0`. -- **Breaking**: Send log output to `stderr` instead of `stdout` [#562](https://github.com/Nukesor/pueue/issues/562). +- Send log output to `stderr` instead of `stdout` [#562](https://github.com/Nukesor/pueue/issues/562). +- Change default log level from error to warning [#562](https://github.com/Nukesor/pueue/issues/562). ### Add diff --git a/pueue/src/bin/pueue.rs b/pueue/src/bin/pueue.rs index ab97f629..6fb23a28 100644 --- a/pueue/src/bin/pueue.rs +++ b/pueue/src/bin/pueue.rs @@ -35,10 +35,10 @@ async fn main() -> Result<()> { // Init the logger and set the verbosity level depending on the `-v` flags. let level = match opt.verbose { - 0 => LevelFilter::Error, - 1 => LevelFilter::Warn, - 2 => LevelFilter::Info, - _ => LevelFilter::Debug, + 0 => LevelFilter::Warn, + 1 => LevelFilter::Info, + 2 => LevelFilter::Debug, + _ => LevelFilter::Trace, }; // Try to initialize the logger with the timezone set to the Local time of the machine. diff --git a/pueue/src/bin/pueued.rs b/pueue/src/bin/pueued.rs index b637ba39..6ba11eb7 100644 --- a/pueue/src/bin/pueued.rs +++ b/pueue/src/bin/pueued.rs @@ -19,10 +19,10 @@ async fn main() -> Result<()> { // Set the verbosity level of the logger. let level = match opt.verbose { - 0 => LevelFilter::Error, - 1 => LevelFilter::Warn, - 2 => LevelFilter::Info, - _ => LevelFilter::Debug, + 0 => LevelFilter::Warn, + 1 => LevelFilter::Info, + 2 => LevelFilter::Debug, + _ => LevelFilter::Trace, }; // Try to initialize the logger with the timezone set to the Local time of the machine. diff --git a/pueue/src/client/client.rs b/pueue/src/client/client.rs index 7dd145b6..d67b8c11 100644 --- a/pueue/src/client/client.rs +++ b/pueue/src/client/client.rs @@ -5,7 +5,7 @@ use std::{borrow::Cow, collections::HashMap}; use anyhow::{bail, Context, Result}; use clap::crate_version; use crossterm::tty::IsTty; -use log::error; +use log::{error, warn}; use pueue_lib::network::message::*; use pueue_lib::network::protocol::*; @@ -110,7 +110,7 @@ impl Client { }; if show_warning { - error!( + warn!( "Different daemon version detected '{version}'. Consider restarting the daemon." ); }