generated from PlexSheep/baserepo
refactor(log): apply more clippy findings
cargo devel CI / cargo CI (push) Failing after 1m44s
Details
cargo devel CI / cargo CI (push) Failing after 1m44s
Details
This commit is contained in:
parent
73f935d9b2
commit
b2bf00db46
|
@ -23,10 +23,17 @@ struct Cli {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
let _logger = Logger::builder()
|
let _logger = {
|
||||||
.max_level(cli.verbosity.level())
|
let mut this = {
|
||||||
.show_time(false)
|
let mut this = Logger::builder();
|
||||||
.build();
|
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());
|
debug!("logger initialized with level: {}", cli.verbosity.level());
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,17 @@ enum ReplCommand {
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
// You would normally make a proper cli interface with clap before entering the repl. This is
|
// You would normally make a proper cli interface with clap before entering the repl. This is
|
||||||
// omitted here for brevity
|
// omitted here for brevity
|
||||||
let _logger = Logger::builder()
|
let _logger = {
|
||||||
.show_time(false)
|
let mut this = {
|
||||||
.max_level(Level::INFO)
|
let mut this = Logger::builder();
|
||||||
.build()?;
|
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.
|
// the compiler can infer that we want to use the ReplCommand enum.
|
||||||
let mut repl = DefaultRepl::<ReplCommand>::default();
|
let mut repl = DefaultRepl::<ReplCommand>::default();
|
||||||
|
|
|
@ -378,35 +378,35 @@ impl Logger {
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
{
|
{
|
||||||
error!("{}", printable)
|
error!("{}", printable);
|
||||||
}
|
}
|
||||||
/// ## logging at [`Level::WARN`]
|
/// ## logging at [`Level::WARN`]
|
||||||
pub fn warn<T>(&self, printable: T)
|
pub fn warn<T>(&self, printable: T)
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
{
|
{
|
||||||
warn!("{}", printable)
|
warn!("{}", printable);
|
||||||
}
|
}
|
||||||
/// ## logging at [`Level::INFO`]
|
/// ## logging at [`Level::INFO`]
|
||||||
pub fn info<T>(&self, printable: T)
|
pub fn info<T>(&self, printable: T)
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
{
|
{
|
||||||
info!("{}", printable)
|
info!("{}", printable);
|
||||||
}
|
}
|
||||||
/// ## logging at [`Level::DEBUG`]
|
/// ## logging at [`Level::DEBUG`]
|
||||||
pub fn debug<T>(&self, printable: T)
|
pub fn debug<T>(&self, printable: T)
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
{
|
{
|
||||||
debug!("{}", printable)
|
debug!("{}", printable);
|
||||||
}
|
}
|
||||||
/// ## logging at [`Level::TRACE`]
|
/// ## logging at [`Level::TRACE`]
|
||||||
pub fn trace<T>(&self, printable: T)
|
pub fn trace<T>(&self, printable: T)
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
{
|
{
|
||||||
trace!("{}", printable)
|
trace!("{}", printable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +430,6 @@ impl Default for Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_file_appender(log_dir: PathBuf) -> NonBlocking {
|
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
|
tracing_appender::non_blocking(file_appender).0
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue