From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 1/1] router: add init_cli_logger helper function
Date: Tue, 10 May 2022 09:01:50 +0000 [thread overview]
Message-ID: <20220510090158.33504-3-h.laimer@proxmox.com> (raw)
In-Reply-To: <20220510090158.33504-1-h.laimer@proxmox.com>
Signed-off-by: Hannes Laimer <h.laimer@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 d9f47ea..29c717c 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.19.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
next prev parent reply other threads:[~2022-05-10 9:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 9:01 [pbs-devel] [PATCH-SERIES] replace print by log macro in libraries Hannes Laimer
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 1/9] bins: init cli logger Hannes Laimer
2022-05-10 9:01 ` Hannes Laimer [this message]
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 2/9] pbs-client: replace print with log macro Hannes Laimer
2022-05-31 8:38 ` Wolfgang Bumiller
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 3/9] pbs-datastore: " Hannes Laimer
2022-05-31 8:44 ` Wolfgang Bumiller
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 4/9] pbs-fuse+pbs-tape: " Hannes Laimer
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 5/9] proxmox-backup-client: " Hannes Laimer
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 6/9] proxmox-file-restore: " Hannes Laimer
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 7/9] proxmox-rest-server: " Hannes Laimer
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 8/9] " Hannes Laimer
2022-05-31 8:42 ` Wolfgang Bumiller
2022-05-10 9:01 ` [pbs-devel] [PATCH proxmox-backup rebased 9/9] docs: add note for setting verbosity level Hannes Laimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220510090158.33504-3-h.laimer@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.