Skip to content

feat: add --log-to-stdout for command #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COPY dragonfly-client-util/src ./dragonfly-client-util/src
COPY dragonfly-client-init/Cargo.toml ./dragonfly-client-init/Cargo.toml
COPY dragonfly-client-init/src ./dragonfly-client-init/src

RUN cargo build --release --verbose --bin dfget --bin dfdaemon --bin dfcache
RUN cargo build --release --log-to-stdout --bin dfget --bin dfdaemon --bin dfcache

FROM public.ecr.aws/docker/library/alpine:3.20 AS health

Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COPY dragonfly-client-util/src ./dragonfly-client-util/src
COPY dragonfly-client-init/Cargo.toml ./dragonfly-client-init/Cargo.toml
COPY dragonfly-client-init/src ./dragonfly-client-init/src

RUN cargo build --verbose --bin dfget --bin dfdaemon --bin dfcache
RUN cargo build --log-to-stdout --bin dfget --bin dfdaemon --bin dfcache

RUN cargo install flamegraph --root /usr/local
RUN cargo install bottom --locked --root /usr/local
Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile.dfinit
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COPY dragonfly-client-util/src ./dragonfly-client-util/src
COPY dragonfly-client-init/Cargo.toml ./dragonfly-client-init/Cargo.toml
COPY dragonfly-client-init/src ./dragonfly-client-init/src

RUN cargo build --release --verbose --bin dfinit
RUN cargo build --release --log-to-stdout --bin dfinit

FROM public.ecr.aws/debian/debian:bookworm-slim

Expand Down
2 changes: 1 addition & 1 deletion ci/dfdaemon.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=network-online.target
After=network.target

[Service]
ExecStart=/usr/bin/dfdaemon --config /etc/dragonfly/dfdaemon.yaml --verbose
ExecStart=/usr/bin/dfdaemon --config /etc/dragonfly/dfdaemon.yaml --log-to-stdout

Type=simple
Environment=HOME=/root
Expand Down
2 changes: 1 addition & 1 deletion docs/performance-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cargo build --release --bin dfdaemon

```bash
# prepare client.yaml by yourself.
./target/release/dfdaemon --config client.yaml -l info --verbose
./target/release/dfdaemon --config client.yaml -l info --log-to-stdout
```

## FlameGraph
Expand Down
2 changes: 1 addition & 1 deletion dragonfly-client-backend/examples/plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cargo build --all && mv target/debug/libhdfs.so {plugin_dir}/backend/libhdfs.so
## Run Client with Plugin

```shell
$ cargo run --bin dfdaemon -- --config {config_dir}/config.yaml -l info --verbose
$ cargo run --bin dfdaemon -- --config {config_dir}/config.yaml -l info --log-to-stdout
INFO load [http] builtin backend
INFO load [https] builtin backend
INFO load [hdfs] plugin backend
Expand Down
10 changes: 3 additions & 7 deletions dragonfly-client-init/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ struct Args {
)]
log_max_files: usize,

#[arg(
long = "verbose",
default_value_t = false,
help = "Specify whether to print log"
)]
verbose: bool,
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
log_to_stdout: bool,

#[arg(
short = 'V',
Expand All @@ -95,7 +91,7 @@ async fn main() -> Result<(), anyhow::Error> {
args.log_max_files,
None,
None,
args.verbose,
args.log_to_stdout,
);

// Load config.
Expand Down
10 changes: 3 additions & 7 deletions dragonfly-client/src/bin/dfcache/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,8 @@ pub struct ExportCommand {
)]
log_max_files: usize,

#[arg(
long = "verbose",
default_value_t = false,
help = "Specify whether to print log"
)]
verbose: bool,
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
log_to_stdout: bool,
}

/// Implement the execute for ExportCommand.
Expand All @@ -138,7 +134,7 @@ impl ExportCommand {
self.log_max_files,
None,
None,
self.verbose,
self.log_to_stdout,
);

// Validate the command line arguments.
Expand Down
10 changes: 3 additions & 7 deletions dragonfly-client/src/bin/dfcache/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,8 @@ pub struct ImportCommand {
)]
log_max_files: usize,

#[arg(
long = "verbose",
default_value_t = false,
help = "Specify whether to print log"
)]
verbose: bool,
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
log_to_stdout: bool,
}

/// Implement the execute for ImportCommand.
Expand All @@ -144,7 +140,7 @@ impl ImportCommand {
self.log_max_files,
None,
None,
self.verbose,
self.log_to_stdout,
);

// Validate the command line arguments.
Expand Down
10 changes: 3 additions & 7 deletions dragonfly-client/src/bin/dfcache/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ pub struct StatCommand {
)]
log_max_files: usize,

#[arg(
long = "verbose",
default_value_t = false,
help = "Specify whether to print log"
)]
verbose: bool,
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
log_to_stdout: bool,
}

/// Implement the execute for StatCommand.
Expand All @@ -90,7 +86,7 @@ impl StatCommand {
self.log_max_files,
None,
None,
self.verbose,
self.log_to_stdout,
);

// Get dfdaemon download client.
Expand Down
10 changes: 3 additions & 7 deletions dragonfly-client/src/bin/dfdaemon/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,8 @@ struct Args {
)]
log_max_files: usize,

#[arg(
long = "verbose",
default_value_t = true,
help = "Specify whether to print log"
)]
verbose: bool,
#[arg(long, default_value_t = true, help = "Specify whether to print log")]
log_to_stdout: bool,

#[arg(
short = 'V',
Expand Down Expand Up @@ -151,7 +147,7 @@ async fn main() -> Result<(), anyhow::Error> {
args.log_max_files,
config.tracing.addr.to_owned(),
Some(config.host.clone()),
args.verbose,
args.log_to_stdout,
);

// Initialize storage.
Expand Down
10 changes: 3 additions & 7 deletions dragonfly-client/src/bin/dfget/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,8 @@ struct Args {
)]
log_max_files: usize,

#[arg(
long = "verbose",
default_value_t = false,
help = "Specify whether to print log"
)]
verbose: bool,
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
log_to_stdout: bool,

#[arg(
short = 'V',
Expand All @@ -309,7 +305,7 @@ async fn main() -> anyhow::Result<()> {
args.log_max_files,
None,
None,
args.verbose,
args.log_to_stdout,
);

// Validate command line arguments.
Expand Down
4 changes: 2 additions & 2 deletions dragonfly-client/src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn init_tracing(
log_max_files: usize,
jaeger_addr: Option<String>,
host: Option<Host>,
verbose: bool,
log_to_stdout: bool,
) -> Vec<WorkerGuard> {
let mut guards = vec![];

Expand All @@ -53,7 +53,7 @@ pub fn init_tracing(
guards.push(stdout_guard);

// Initialize stdout layer.
let stdout_filter = if verbose {
let stdout_filter = if log_to_stdout {
LevelFilter::DEBUG
} else {
LevelFilter::OFF
Expand Down