Skip to content

Commit 6176027

Browse files
nightkrTechassi
authored andcommitted
Switch to operator-rs' logging
1 parent 9338c2b commit 6176027

4 files changed

Lines changed: 33 additions & 6 deletions

File tree

crates/containerdebug/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ hickory-resolver = "0.24.1"
1010
local-ip-address = "0.6.3"
1111
serde = { version = "1.0.210", features = ["derive"] }
1212
serde_json = "1.0.128"
13-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.78.0", version = "0.78.0" }
13+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs", version = "0.81.0" }
1414
sysinfo = "0.32.0"
1515
tracing = "0.1.40"
16-
tracing-subscriber = "0.3.18"
1716
users = "0.11.0"
17+
18+
[build-dependencies]
19+
built = { version = "0.7", features = ["chrono", "git2"] }

crates/containerdebug/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
built::write_built_file().unwrap();
3+
}

crates/containerdebug/src/main.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
mod system_information;
22

3-
use clap::Parser;
3+
use clap::{crate_description, crate_version, Parser};
4+
use stackable_operator::logging::TracingTarget;
45
use std::path::PathBuf;
56

67
use crate::system_information::SystemInformation;
78
use std::time::Instant;
89

10+
const APP_NAME: &str = "containerdebug";
11+
912
/// Collects and prints helpful debugging information about the environment that it is running in.
1013
#[derive(clap::Parser)]
1114
struct Opts {
@@ -21,12 +24,31 @@ struct Opts {
2124

2225
#[clap(long, short = 'o')]
2326
output: Option<PathBuf>,
27+
28+
/// Tracing log collector system
29+
#[arg(long, env, default_value_t, value_enum)]
30+
pub tracing_target: TracingTarget,
2431
}
2532

26-
fn main() {
27-
tracing_subscriber::fmt().init();
33+
mod built_info {
34+
include!(concat!(env!("OUT_DIR"), "/built.rs"));
35+
}
2836

37+
fn main() {
2938
let opts = Opts::parse();
39+
stackable_operator::logging::initialize_logging(
40+
"CONTAINERDEBUG_LOG",
41+
APP_NAME,
42+
opts.tracing_target,
43+
);
44+
stackable_operator::utils::print_startup_string(
45+
crate_description!(),
46+
crate_version!(),
47+
built_info::GIT_VERSION,
48+
built_info::TARGET,
49+
built_info::BUILT_TIME_UTC,
50+
built_info::RUSTC_VERSION,
51+
);
3052

3153
let mut next_run = Instant::now();
3254
loop {

crates/containerdebug/src/system_information/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use hickory_resolver::{system_conf::read_system_conf, Resolver};
22
use local_ip_address::list_afinet_netifas;
33
use serde::Serialize;
44
use std::{
5-
collections::{BTreeSet, HashMap, HashSet},
5+
collections::{BTreeSet, HashMap},
66
net::IpAddr,
77
time::Duration,
88
};

0 commit comments

Comments
 (0)