mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
ch-remote: add env_logger, log messages to stderr
Until now all messages generated using `log::level!` (e.g., `warn!`) have not been printed as `ch-remote` did not register a logger. Furthermore, replace all `eprintln!` with `error!` to align formatting for consistency. Signed-off-by: Maximilian Güntner <code@mguentner.de>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -409,6 +409,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"dhat",
|
"dhat",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"env_logger",
|
||||||
"epoll",
|
"epoll",
|
||||||
"event_monitor",
|
"event_monitor",
|
||||||
"hypervisor",
|
"hypervisor",
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ anyhow = "1.0.94"
|
|||||||
api_client = { path = "api_client" }
|
api_client = { path = "api_client" }
|
||||||
clap = { version = "4.5.13", features = ["string"] }
|
clap = { version = "4.5.13", features = ["string"] }
|
||||||
dhat = { version = "0.3.3", optional = true }
|
dhat = { version = "0.3.3", optional = true }
|
||||||
|
env_logger = { workspace = true }
|
||||||
epoll = "4.3.3"
|
epoll = "4.3.3"
|
||||||
event_monitor = { path = "event_monitor" }
|
event_monitor = { path = "event_monitor" }
|
||||||
hypervisor = { path = "hypervisor" }
|
hypervisor = { path = "hypervisor" }
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use api_client::{
|
|||||||
Error as ApiClientError,
|
Error as ApiClientError,
|
||||||
};
|
};
|
||||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||||
|
use log::error;
|
||||||
use option_parser::{ByteSized, ByteSizedParseError};
|
use option_parser::{ByteSized, ByteSizedParseError};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use vmm::config::RestoreConfig;
|
use vmm::config::RestoreConfig;
|
||||||
@@ -1071,6 +1072,7 @@ fn get_cli_commands_sorted() -> Box<[Command]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
env_logger::init();
|
||||||
let app = Command::new("ch-remote")
|
let app = Command::new("ch-remote")
|
||||||
.author(env!("CARGO_PKG_AUTHORS"))
|
.author(env!("CARGO_PKG_AUTHORS"))
|
||||||
.version(env!("BUILD_VERSION"))
|
.version(env!("BUILD_VERSION"))
|
||||||
@@ -1092,7 +1094,7 @@ fn main() {
|
|||||||
#[cfg(not(feature = "dbus_api"))]
|
#[cfg(not(feature = "dbus_api"))]
|
||||||
(Some(api_sock),) => TargetApi::HttpApi(
|
(Some(api_sock),) => TargetApi::HttpApi(
|
||||||
UnixStream::connect(api_sock).unwrap_or_else(|e| {
|
UnixStream::connect(api_sock).unwrap_or_else(|e| {
|
||||||
eprintln!("Error opening HTTP socket: {e}");
|
error!("Error opening HTTP socket: {e}");
|
||||||
process::exit(1)
|
process::exit(1)
|
||||||
}),
|
}),
|
||||||
PhantomData,
|
PhantomData,
|
||||||
@@ -1100,7 +1102,7 @@ fn main() {
|
|||||||
#[cfg(feature = "dbus_api")]
|
#[cfg(feature = "dbus_api")]
|
||||||
(Some(api_sock), None, None) => TargetApi::HttpApi(
|
(Some(api_sock), None, None) => TargetApi::HttpApi(
|
||||||
UnixStream::connect(api_sock).unwrap_or_else(|e| {
|
UnixStream::connect(api_sock).unwrap_or_else(|e| {
|
||||||
eprintln!("Error opening HTTP socket: {e}");
|
error!("Error opening HTTP socket: {e}");
|
||||||
process::exit(1)
|
process::exit(1)
|
||||||
}),
|
}),
|
||||||
PhantomData,
|
PhantomData,
|
||||||
@@ -1114,19 +1116,19 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.map_err(Error::DBusApiClient)
|
.map_err(Error::DBusApiClient)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
eprintln!("Error creating D-Bus proxy: {e}");
|
error!("Error creating D-Bus proxy: {e}");
|
||||||
process::exit(1)
|
process::exit(1)
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
#[cfg(feature = "dbus_api")]
|
#[cfg(feature = "dbus_api")]
|
||||||
(Some(_), Some(_) | None, Some(_) | None) => {
|
(Some(_), Some(_) | None, Some(_) | None) => {
|
||||||
println!(
|
error!(
|
||||||
"`api-socket` and (dbus-service-name or dbus-object-path) are mutually exclusive"
|
"`api-socket` and (dbus-service-name or dbus-object-path) are mutually exclusive"
|
||||||
);
|
);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("Please either provide the api-socket option or dbus-service-name and dbus-object-path options");
|
error!("Please either provide the api-socket option or dbus-service-name and dbus-object-path options");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user