idk why this isn't in master yet #94

Merged
cscherrNT merged 79 commits from devel into master 2024-07-22 13:30:20 +02:00
3 changed files with 28 additions and 14 deletions
Showing only changes of commit b2bf00db46 - Show all commits

View File

@ -23,9 +23,16 @@ struct Cli {
fn main() {
let cli = Cli::parse();
let _logger = Logger::builder()
.max_level(cli.verbosity.level())
.show_time(false)
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,9 +31,16 @@ 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)
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.

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
}