refactor(log): apply more clippy findings
cargo devel CI / cargo CI (push) Failing after 1m44s Details

This commit is contained in:
Christoph J. Scherr 2024-07-09 18:25:50 +02:00
parent 73f935d9b2
commit b2bf00db46
3 changed files with 28 additions and 14 deletions

View File

@ -23,10 +23,17 @@ struct Cli {
fn main() {
let cli = Cli::parse();
let _logger = Logger::builder()
.max_level(cli.verbosity.level())
.show_time(false)
.build();
let _logger = {
let mut this = {
let mut this = Logger::builder();
let max_level = cli.verbosity.level();
this.max_level = max_level;
this
};
this.show_time = false;
this
}
.build();
debug!("logger initialized with level: {}", cli.verbosity.level());

View File

@ -31,10 +31,17 @@ enum ReplCommand {
fn main() -> anyhow::Result<()> {
// You would normally make a proper cli interface with clap before entering the repl. This is
// omitted here for brevity
let _logger = Logger::builder()
.show_time(false)
.max_level(Level::INFO)
.build()?;
let _logger = {
let mut this = {
let mut this = Logger::builder();
this.show_time = false;
this
};
let max_level = Level::INFO;
this.max_level = max_level;
this
}
.build()?;
// the compiler can infer that we want to use the ReplCommand enum.
let mut repl = DefaultRepl::<ReplCommand>::default();

View File

@ -378,35 +378,35 @@ impl Logger {
where
T: fmt::Display,
{
error!("{}", printable)
error!("{}", printable);
}
/// ## logging at [`Level::WARN`]
pub fn warn<T>(&self, printable: T)
where
T: fmt::Display,
{
warn!("{}", printable)
warn!("{}", printable);
}
/// ## logging at [`Level::INFO`]
pub fn info<T>(&self, printable: T)
where
T: fmt::Display,
{
info!("{}", printable)
info!("{}", printable);
}
/// ## logging at [`Level::DEBUG`]
pub fn debug<T>(&self, printable: T)
where
T: fmt::Display,
{
debug!("{}", printable)
debug!("{}", printable);
}
/// ## logging at [`Level::TRACE`]
pub fn trace<T>(&self, printable: T)
where
T: fmt::Display,
{
trace!("{}", printable)
trace!("{}", printable);
}
}
@ -430,6 +430,6 @@ impl Default for Logger {
}
fn new_file_appender(log_dir: PathBuf) -> NonBlocking {
let file_appender = tracing_appender::rolling::daily(log_dir.clone(), "log");
let file_appender = tracing_appender::rolling::daily(log_dir, "log");
tracing_appender::non_blocking(file_appender).0
}