Refactor logging
To supporte more than a single log level `log` and `env_logger` crates are used. For the application to support the different type of argument, the verbose argument definition was adapted.
This commit is contained in:
parent
6a41335603
commit
12b117db7e
8 changed files with 107 additions and 36 deletions
|
@ -1,5 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use clap::Clap;
|
||||
use log::{info, log_enabled, Level::Info};
|
||||
use posixmq::PosixMq;
|
||||
use std::fs;
|
||||
|
||||
|
@ -35,7 +36,7 @@ fn msg_default() -> usize {
|
|||
}
|
||||
|
||||
impl Create {
|
||||
pub fn run(&self, verbose: bool) -> Result<()> {
|
||||
pub fn run(&self) -> Result<()> {
|
||||
let mq = &mut posixmq::OpenOptions::readonly();
|
||||
|
||||
if let Some(m) = &self.permissions {
|
||||
|
@ -47,11 +48,11 @@ impl Create {
|
|||
.create_new()
|
||||
.open(&self.queue)?;
|
||||
|
||||
if verbose {
|
||||
if log_enabled!(Info) {
|
||||
let mq = PosixMq::open(&self.queue)?;
|
||||
let attributes = mq.attributes()?;
|
||||
|
||||
println!("Created message queue: {} with attributes msgsize: {}, capacity: {}, current_messages: {}",
|
||||
info!("Created message queue: {} with attributes msgsize: {}, capacity: {}, current_messages: {}",
|
||||
&self.queue,
|
||||
&attributes.max_msg_len,
|
||||
&attributes.capacity,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue