[pbs-devel] applied: [PATCH proxmox v3 1/1] router: add init_cli_logger helper function

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Jun 21 10:40:45 CEST 2022


applied & bumped proxmox-router

On Wed, Jun 15, 2022 at 08:19:47AM +0000, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
>  proxmox-router/Cargo.toml     |  1 +
>  proxmox-router/src/cli/mod.rs | 11 +++++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/proxmox-router/Cargo.toml b/proxmox-router/Cargo.toml
> index 576a29e..1e16e23 100644
> --- a/proxmox-router/Cargo.toml
> +++ b/proxmox-router/Cargo.toml
> @@ -10,6 +10,7 @@ exclude = [ "debian" ]
>  
>  [dependencies]
>  anyhow = "1.0"
> +env_logger = "0.9"
>  http = "0.2"
>  hyper = { version = "0.14", features = [ "full" ] }
>  nix = "0.24.1"
> diff --git a/proxmox-router/src/cli/mod.rs b/proxmox-router/src/cli/mod.rs
> index cc72402..41944dc 100644
> --- a/proxmox-router/src/cli/mod.rs
> +++ b/proxmox-router/src/cli/mod.rs
> @@ -49,6 +49,17 @@ pub use readline::*;
>  /// return a list of all possible values.
>  pub type CompletionFunction = fn(&str, &HashMap<String, String>) -> Vec<String>;
>  
> +/// Initialize default logger for CLI binaries
> +pub fn init_cli_logger(env_var_name: &str, default_log_level: &str) {
> +    env_logger::Builder::from_env(env_logger::Env::new().filter_or(env_var_name, default_log_level))
> +        .write_style(env_logger::WriteStyle::Never)
> +        .format_level(false)
> +        .format_module_path(false)
> +        .format_target(false)
> +        .format_timestamp(None)
> +        .init();
> +}
> +
>  /// Define a simple CLI command.
>  pub struct CliCommand {
>      /// The Schema definition.
> -- 
> 2.30.2





More information about the pbs-devel mailing list