From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 3/4] log: use new init functions
Date: Mon, 9 Dec 2024 11:46:05 +0100 [thread overview]
Message-ID: <20241209104606.263045-4-g.goller@proxmox.com> (raw)
In-Reply-To: <20241209104606.263045-1-g.goller@proxmox.com>
Use new logger init functions that are more descriptive, less
product-bound.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
pbs-tape/src/bin/pmt.rs | 3 +--
pbs-tape/src/bin/pmtx.rs | 3 +--
proxmox-backup-client/src/main.rs | 4 ++--
proxmox-file-restore/src/main.rs | 3 +--
pxar-bin/src/main.rs | 5 +++--
src/bin/proxmox-backup-api.rs | 3 +--
src/bin/proxmox-backup-debug.rs | 4 ++--
src/bin/proxmox-backup-manager.rs | 3 +--
src/bin/proxmox-backup-proxy.rs | 3 +--
src/bin/proxmox-tape.rs | 4 ++--
src/bin/sg-tape-cmd.rs | 3 +--
11 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/pbs-tape/src/bin/pmt.rs b/pbs-tape/src/bin/pmt.rs
index 9e39dbe16b2f..eecb0562aca9 100644
--- a/pbs-tape/src/bin/pmt.rs
+++ b/pbs-tape/src/bin/pmt.rs
@@ -15,7 +15,6 @@
use anyhow::{bail, Error};
use serde_json::Value;
-use proxmox_log::init_cli_logger;
use proxmox_router::cli::*;
use proxmox_router::RpcEnvironment;
use proxmox_schema::{api, ArraySchema, IntegerSchema, Schema, StringSchema};
@@ -800,7 +799,7 @@ fn options(
}
fn main() -> Result<(), Error> {
- init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
let uid = nix::unistd::Uid::current();
diff --git a/pbs-tape/src/bin/pmtx.rs b/pbs-tape/src/bin/pmtx.rs
index 303353e6bfd3..627a2c7b8389 100644
--- a/pbs-tape/src/bin/pmtx.rs
+++ b/pbs-tape/src/bin/pmtx.rs
@@ -16,7 +16,6 @@ use std::fs::File;
use anyhow::{bail, Error};
use serde_json::Value;
-use proxmox_log::init_cli_logger;
use proxmox_router::cli::*;
use proxmox_router::RpcEnvironment;
use proxmox_schema::api;
@@ -388,7 +387,7 @@ fn scan(param: Value) -> Result<(), Error> {
}
fn main() -> Result<(), Error> {
- init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
let uid = nix::unistd::Uid::current();
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 632a291707c7..1b3f2d584a98 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -16,7 +16,6 @@ use xdg::BaseDirectories;
use pathpatterns::{MatchEntry, MatchType, PatternFlag};
use proxmox_async::blocking::TokioWriterAdapter;
use proxmox_io::StdChannelWriter;
-use proxmox_log::init_cli_logger;
use proxmox_router::{cli::*, ApiMethod, RpcEnvironment};
use proxmox_schema::api;
use proxmox_sys::fs::{file_get_json, image_size, replace_file, CreateOptions};
@@ -1962,7 +1961,8 @@ impl ReadAt for BufferedDynamicReadAt {
fn main() {
pbs_tools::setup_libc_malloc_opts();
- init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", proxmox_log::LevelFilter::INFO)
+ .expect("failed to initiate logger");
let backup_cmd_def = CliCommand::new(&API_METHOD_CREATE_BACKUP)
.arg_param(&["backupspec"])
diff --git a/proxmox-file-restore/src/main.rs b/proxmox-file-restore/src/main.rs
index 572e2d188b42..ae8a5b2f2d7a 100644
--- a/proxmox-file-restore/src/main.rs
+++ b/proxmox-file-restore/src/main.rs
@@ -10,7 +10,6 @@ use serde_json::{json, Value};
use tokio::io::AsyncWriteExt;
use proxmox_compression::zstd::ZstdEncoder;
-use proxmox_log::init_cli_logger;
use proxmox_router::cli::{
complete_file_name, default_table_format_options, format_and_print_result_full,
get_output_format, run_cli_command, CliCommand, CliCommandMap, CliEnvironment, ColumnConfig,
@@ -629,7 +628,7 @@ fn main() {
true => proxmox_log::LevelFilter::DEBUG,
false => proxmox_log::LevelFilter::INFO,
};
- init_cli_logger("PBS_LOG", loglevel).expect("failed to initiate logger");
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", loglevel).expect("failed to initiate logger");
let list_cmd_def = CliCommand::new(&API_METHOD_LIST)
.arg_param(&["snapshot", "path"])
diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs
index 7dff1e38c252..2e12226324af 100644
--- a/pxar-bin/src/main.rs
+++ b/pxar-bin/src/main.rs
@@ -22,7 +22,7 @@ use pbs_client::pxar::{
use pxar::EntryKind;
use proxmox_human_byte::HumanByte;
-use proxmox_log::{debug, enabled, error, init_cli_logger, Level};
+use proxmox_log::{debug, enabled, error, Level};
use proxmox_router::cli::*;
use proxmox_schema::api;
@@ -574,7 +574,8 @@ fn dump_archive(archive: String, payload_input: Option<String>) -> Result<(), Er
}
fn main() {
- init_cli_logger("PXAR_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
+ proxmox_log::init::stderr_or_tasklog("PXAR_LOG", proxmox_log::LevelFilter::INFO)
+ .expect("failed to initiate logger");
let cmd_def = CliCommandMap::new()
.insert(
diff --git a/src/bin/proxmox-backup-api.rs b/src/bin/proxmox-backup-api.rs
index 7a72d49a434d..388725b1065c 100644
--- a/src/bin/proxmox-backup-api.rs
+++ b/src/bin/proxmox-backup-api.rs
@@ -8,7 +8,6 @@ use hyper::{Body, StatusCode};
use tracing::level_filters::LevelFilter;
use proxmox_lang::try_block;
-use proxmox_log::init_logger;
use proxmox_rest_server::{ApiConfig, RestServer};
use proxmox_router::RpcEnvironmentType;
use proxmox_sys::fs::CreateOptions;
@@ -41,7 +40,7 @@ fn get_index() -> Pin<Box<dyn Future<Output = Response<Body>> + Send>> {
}
async fn run() -> Result<(), Error> {
- init_logger("PBS_LOG", LevelFilter::INFO)?;
+ proxmox_log::init::journald_or_tasklog("PBS_LOG", LevelFilter::INFO)?;
config::create_configdir()?;
diff --git a/src/bin/proxmox-backup-debug.rs b/src/bin/proxmox-backup-debug.rs
index 35ad11c70e7e..4be910dc48f9 100644
--- a/src/bin/proxmox-backup-debug.rs
+++ b/src/bin/proxmox-backup-debug.rs
@@ -1,4 +1,3 @@
-use proxmox_log::init_cli_logger;
use proxmox_router::{
cli::{run_cli_command, CliCommandMap, CliEnvironment},
RpcEnvironment,
@@ -8,7 +7,8 @@ mod proxmox_backup_debug;
use proxmox_backup_debug::*;
fn main() {
- init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", proxmox_log::LevelFilter::INFO)
+ .expect("failed to initiate logger");
let cmd_def = CliCommandMap::new()
.insert("inspect", inspect::inspect_commands())
diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs
index 02ca0d028225..ac240e138591 100644
--- a/src/bin/proxmox-backup-manager.rs
+++ b/src/bin/proxmox-backup-manager.rs
@@ -3,7 +3,6 @@ use std::io::{self, Write};
use std::str::FromStr;
use anyhow::{format_err, Error};
-use proxmox_log::init_cli_logger;
use serde_json::{json, Value};
use proxmox_router::{cli::*, RpcEnvironment};
@@ -618,7 +617,7 @@ async fn get_versions(verbose: bool, param: Value) -> Result<Value, Error> {
}
async fn run() -> Result<(), Error> {
- init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
proxmox_backup::server::notifications::init()?;
let cmd_def = CliCommandMap::new()
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index ce1be1c0d8d9..9110013e45ec 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -16,7 +16,6 @@ use openssl::ssl::SslAcceptor;
use serde_json::{json, Value};
use proxmox_lang::try_block;
-use proxmox_log::init_logger;
use proxmox_router::{RpcEnvironment, RpcEnvironmentType};
use proxmox_sys::fs::CreateOptions;
use proxmox_sys::logrotate::LogRotate;
@@ -179,7 +178,7 @@ async fn get_index_future(env: RestEnvironment, parts: Parts) -> Response<Body>
}
async fn run() -> Result<(), Error> {
- init_logger("PBS_LOG", LevelFilter::INFO)?;
+ proxmox_log::init::journald_or_tasklog("PBS_LOG", LevelFilter::INFO)?;
proxmox_backup::auth_helpers::setup_auth_context(false);
proxmox_backup::server::notifications::init()?;
diff --git a/src/bin/proxmox-tape.rs b/src/bin/proxmox-tape.rs
index 8e8584b35637..930a4e0b44cc 100644
--- a/src/bin/proxmox-tape.rs
+++ b/src/bin/proxmox-tape.rs
@@ -5,7 +5,6 @@ use serde_json::{json, Value};
use proxmox_human_byte::HumanByte;
use proxmox_io::ReadExt;
-use proxmox_log::init_cli_logger;
use proxmox_router::cli::*;
use proxmox_router::RpcEnvironment;
use proxmox_schema::api;
@@ -998,7 +997,8 @@ async fn catalog_media(mut param: Value) -> Result<(), Error> {
}
fn main() {
- init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", proxmox_log::LevelFilter::INFO)
+ .expect("failed to initiate logger");
let cmd_def = CliCommandMap::new()
.insert(
diff --git a/src/bin/sg-tape-cmd.rs b/src/bin/sg-tape-cmd.rs
index cd14b660a68a..933290c7c663 100644
--- a/src/bin/sg-tape-cmd.rs
+++ b/src/bin/sg-tape-cmd.rs
@@ -10,7 +10,6 @@ use pbs_tape::sg_tape::SgTape;
use proxmox_backup::tape::encryption_keys::load_key;
use serde_json::Value;
-use proxmox_log::init_cli_logger;
use proxmox_router::{cli::*, RpcEnvironment};
use proxmox_schema::api;
use proxmox_uuid::Uuid;
@@ -125,7 +124,7 @@ fn set_encryption(
}
fn main() -> Result<(), Error> {
- init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
+ proxmox_log::init::stderr_or_tasklog("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
// check if we are user root or backup
let backup_uid = pbs_config::backup_user()?.uid;
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-12-09 10:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 10:46 [pbs-devel] [PATCH proxmox{, -backup, -perl-rs} v2 0/4] Rename/Move logging init helper Gabriel Goller
2024-12-09 10:46 ` [pbs-devel] [PATCH proxmox v2 1/4] log: rename/move init functions Gabriel Goller
2024-12-09 10:46 ` [pbs-devel] [PATCH proxmox v2 2/4] log: add logger for perlmod crates Gabriel Goller
2024-12-09 10:46 ` Gabriel Goller [this message]
2024-12-09 10:46 ` [pbs-devel] [PATCH proxmox-perl-rs v2 4/4] log: use new init function, print to stderr and journald Gabriel Goller
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=20241209104606.263045-4-g.goller@proxmox.com \
--to=g.goller@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