move client binaries to tracing

Add tracing logger to all client binaries and remove env_logger.

The reason for this change is twofold: our migration to tracing, and the
behavior when the client calls an api handler directly. Currently the
proxmox-backup-manager calls the api handlers directly for some
commands. This results in no output (on console and task log), as no
tracing logger is instantiated.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
This commit is contained in:
Gabriel Goller 2024-08-29 15:40:40 +02:00 committed by Wolfgang Bumiller
parent ff485aa320
commit dc0de0db10
13 changed files with 27 additions and 14 deletions

View File

@ -23,6 +23,7 @@ udev.workspace = true
proxmox-io.workspace = true
proxmox-lang.workspace=true
proxmox-log.workspace=true
proxmox-sys.workspace = true
proxmox-time.workspace = true
proxmox-uuid.workspace = true

View File

@ -15,6 +15,7 @@
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};
@ -799,7 +800,7 @@ fn options(
}
fn main() -> Result<(), Error> {
init_cli_logger("PBS_LOG", "info");
init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
let uid = nix::unistd::Uid::current();

View File

@ -16,6 +16,7 @@ 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;
@ -387,7 +388,7 @@ fn scan(param: Value) -> Result<(), Error> {
}
fn main() -> Result<(), Error> {
init_cli_logger("PBS_LOG", "info");
init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
let uid = nix::unistd::Uid::current();

View File

@ -24,6 +24,7 @@ pxar.workspace = true
proxmox-async.workspace = true
proxmox-human-byte.workspace = true
proxmox-log.workspace = true
proxmox-io.workspace = true
proxmox-router = { workspace = true, features = [ "cli" ] }
proxmox-schema = { workspace = true, features = [ "api-macro" ] }

View File

@ -16,6 +16,7 @@ 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};
@ -1928,7 +1929,7 @@ impl ReadAt for BufferedDynamicReadAt {
fn main() {
pbs_tools::setup_libc_malloc_opts();
init_cli_logger("PBS_LOG", "info");
init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
let backup_cmd_def = CliCommand::new(&API_METHOD_CREATE_BACKUP)
.arg_param(&["backupspec"])

View File

@ -21,6 +21,7 @@ pxar.workspace = true
proxmox-async.workspace = true
proxmox-compression.workspace = true
proxmox-lang.workspace=true
proxmox-log.workspace=true
proxmox-router = { workspace = true, features = [ "cli" ] }
proxmox-schema = { workspace = true, features = [ "api-macro" ] }
proxmox-sys = { workspace = true, features = [ "logrotate" ] }

View File

@ -9,10 +9,11 @@ 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, init_cli_logger, run_cli_command, CliCommand, CliCommandMap, CliEnvironment,
ColumnConfig, OUTPUT_FORMAT,
get_output_format, run_cli_command, CliCommand, CliCommandMap, CliEnvironment, ColumnConfig,
OUTPUT_FORMAT,
};
use proxmox_router::{http_err, HttpError};
use proxmox_schema::api;
@ -645,10 +646,10 @@ where
fn main() {
let loglevel = match qemu_helper::debug_mode() {
true => "debug",
false => "info",
true => proxmox_log::LevelFilter::DEBUG,
false => proxmox_log::LevelFilter::INFO,
};
init_cli_logger("PBS_LOG", loglevel);
init_cli_logger("PBS_LOG", loglevel).expect("failed to initiate logger");
let list_cmd_def = CliCommand::new(&API_METHOD_LIST)
.arg_param(&["snapshot", "path"])

View File

@ -21,6 +21,7 @@ pxar.workspace = true
proxmox-async.workspace = true
proxmox-human-byte.workspace = true
proxmox-log.workspace = true
proxmox-router = { workspace = true, features = ["cli", "server"] }
proxmox-schema = { workspace = true, features = [ "api-macro" ] }
proxmox-sys.workspace = true

View File

@ -19,6 +19,7 @@ use pbs_client::pxar::{
use pxar::EntryKind;
use proxmox_human_byte::HumanByte;
use proxmox_log::init_cli_logger;
use proxmox_router::cli::*;
use proxmox_schema::api;
@ -568,7 +569,7 @@ fn dump_archive(archive: String, payload_input: Option<String>) -> Result<(), Er
}
fn main() {
init_cli_logger("PXAR_LOG", "info");
init_cli_logger("PXAR_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
let cmd_def = CliCommandMap::new()
.insert(

View File

@ -1,5 +1,6 @@
use proxmox_log::init_cli_logger;
use proxmox_router::{
cli::{init_cli_logger, run_cli_command, CliCommandMap, CliEnvironment},
cli::{run_cli_command, CliCommandMap, CliEnvironment},
RpcEnvironment,
};
@ -7,7 +8,7 @@ mod proxmox_backup_debug;
use proxmox_backup_debug::*;
fn main() {
init_cli_logger("PBS_LOG", "info");
init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
let cmd_def = CliCommandMap::new()
.insert("inspect", inspect::inspect_commands())

View File

@ -3,6 +3,7 @@ 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};
@ -491,7 +492,7 @@ async fn get_versions(verbose: bool, param: Value) -> Result<Value, Error> {
}
async fn run() -> Result<(), Error> {
init_cli_logger("PBS_LOG", "info");
init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
proxmox_backup::server::notifications::init()?;
let cmd_def = CliCommandMap::new()

View File

@ -5,6 +5,7 @@ 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;
@ -997,7 +998,7 @@ async fn catalog_media(mut param: Value) -> Result<(), Error> {
}
fn main() {
init_cli_logger("PBS_LOG", "info");
init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO).expect("failed to initiate logger");
let cmd_def = CliCommandMap::new()
.insert(

View File

@ -10,6 +10,7 @@ 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;
@ -124,7 +125,7 @@ fn set_encryption(
}
fn main() -> Result<(), Error> {
init_cli_logger("PBS_LOG", "info");
init_cli_logger("PBS_LOG", proxmox_log::LevelFilter::INFO)?;
// check if we are user root or backup
let backup_uid = pbs_config::backup_user()?.uid;