From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v3 1/1] router: add init_cli_logger helper function
Date: Wed, 15 Jun 2022 08:19:47 +0000 [thread overview]
Message-ID: <20220615081957.33511-2-h.laimer@proxmox.com> (raw)
In-Reply-To: <20220615081957.33511-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 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
next prev parent reply other threads:[~2022-06-15 8:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 8:19 [pbs-devel] [PATCH-SERIES proxmox-backup/proxmox v3 00/10] replace print by log macro in libraries Hannes Laimer
2022-06-15 8:19 ` Hannes Laimer [this message]
2022-06-21 8:40 ` [pbs-devel] applied: [PATCH proxmox v3 1/1] router: add init_cli_logger helper function Wolfgang Bumiller
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 01/10] bins: init cli logger Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 02/10] pbs-client: replace print with log macro Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 03/10] pbs-datastore: " Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 04/10] pbs-fuse+pbs-tape: " Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 05/10] proxmox-backup-client: " Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 06/10] proxmox-file-restore: " Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 07/10] proxmox-rest-server: " Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 08/10] " Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 09/10] docs: add note for setting verbosity level Hannes Laimer
2022-06-15 8:19 ` [pbs-devel] [PATCH proxmox-backup v3 10/10] fixed_index: remove unused 'print_info' function Hannes Laimer
2022-06-21 8:46 ` [pbs-devel] applied-series: [PATCH-SERIES proxmox-backup/proxmox v3 00/10] replace print by log macro in libraries Wolfgang Bumiller
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=20220615081957.33511-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox