Skip to content

Commit a2659db

Browse files
authored
feat: remove loging to file in dfget dfcache and dfinit (#1355)
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 63a606f commit a2659db

File tree

12 files changed

+73
-180
lines changed

12 files changed

+73
-180
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ members = [
1212
]
1313

1414
[workspace.package]
15-
version = "1.0.19"
15+
version = "1.0.20"
1616
authors = ["The Dragonfly Developers"]
1717
homepage = "https://d7y.io/"
1818
repository = "https://github.com/dragonflyoss/client.git"
@@ -22,13 +22,13 @@ readme = "README.md"
2222
edition = "2021"
2323

2424
[workspace.dependencies]
25-
dragonfly-client = { path = "dragonfly-client", version = "1.0.19" }
26-
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.0.19" }
27-
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.0.19" }
28-
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.0.19" }
29-
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.0.19" }
30-
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.0.19" }
31-
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.0.19" }
25+
dragonfly-client = { path = "dragonfly-client", version = "1.0.20" }
26+
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.0.20" }
27+
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.0.20" }
28+
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.0.20" }
29+
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.0.20" }
30+
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.0.20" }
31+
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.0.20" }
3232
dragonfly-api = "=2.1.65"
3333
thiserror = "2.0"
3434
futures = "0.3.31"

dragonfly-client-config/src/dfcache.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
use std::path::PathBuf;
18-
1917
/// NAME is the name of dfcache.
2018
pub const NAME: &str = "dfcache";
2119

2220
// DEFAULT_OUTPUT_FILE_MODE defines the default file mode for output files when downloading with dfcache
2321
// using the `--transfer-from-dfdaemon=true` option.
2422
pub const DEFAULT_OUTPUT_FILE_MODE: u32 = 0o644;
2523

26-
/// default_dfcache_log_dir is the default log directory for dfcache.
27-
#[inline]
28-
pub fn default_dfcache_log_dir() -> PathBuf {
29-
crate::default_log_dir().join(NAME)
30-
}
31-
3224
/// default_dfcache_persistent_replica_count is the default replica count of the persistent cache task.
3325
#[inline]
3426
pub fn default_dfcache_persistent_replica_count() -> u64 {

dragonfly-client-config/src/dfget.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
use std::path::PathBuf;
18-
1917
/// NAME is the name of dfget.
2018
pub const NAME: &str = "dfget";
2119

2220
// DEFAULT_OUTPUT_FILE_MODE defines the default file mode for output files when downloading with dfget
2321
// using the `--transfer-from-dfdaemon=true` option.
2422
pub const DEFAULT_OUTPUT_FILE_MODE: u32 = 0o644;
25-
26-
/// default_dfget_log_dir is the default log directory for dfget.
27-
pub fn default_dfget_log_dir() -> PathBuf {
28-
crate::default_log_dir().join(NAME)
29-
}

dragonfly-client-config/src/dfinit.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ pub fn default_dfinit_config_path() -> PathBuf {
3333
crate::default_config_dir().join("dfinit.yaml")
3434
}
3535

36-
/// default_dfinit_log_dir is the default log directory for dfinit.
37-
pub fn default_dfinit_log_dir() -> PathBuf {
38-
crate::default_log_dir().join(NAME)
39-
}
40-
4136
/// default_container_runtime_containerd_config_path is the default containerd configuration path.
4237
#[inline]
4338
fn default_container_runtime_containerd_config_path() -> PathBuf {
@@ -360,12 +355,6 @@ mod tests {
360355
assert_eq!(default_dfinit_config_path(), expected);
361356
}
362357

363-
#[test]
364-
fn test_default_dfinit_log_dir() {
365-
let expected = crate::default_log_dir().join(NAME);
366-
assert_eq!(default_dfinit_log_dir(), expected);
367-
}
368-
369358
#[test]
370359
fn test_container_runtime_default_paths() {
371360
assert_eq!(

dragonfly-client-init/src/bin/main.rs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
use clap::Parser;
18-
use dragonfly_client::tracing::init_tracing;
18+
use dragonfly_client::tracing::init_command_tracing;
1919
use dragonfly_client_config::dfinit;
2020
use dragonfly_client_config::VersionValueParser;
2121
use dragonfly_client_init::container_runtime;
@@ -50,20 +50,6 @@ struct Args {
5050
)]
5151
log_level: Level,
5252

53-
#[arg(
54-
long,
55-
default_value_os_t = dfinit::default_dfinit_log_dir(),
56-
help = "Specify the log directory"
57-
)]
58-
log_dir: PathBuf,
59-
60-
#[arg(
61-
long,
62-
default_value_t = 24,
63-
help = "Specify the max number of log files"
64-
)]
65-
log_max_files: usize,
66-
6753
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
6854
console: bool,
6955

@@ -84,19 +70,7 @@ async fn main() -> Result<(), anyhow::Error> {
8470
let args = Args::parse();
8571

8672
// Initialize tracing.
87-
let _guards = init_tracing(
88-
dfinit::NAME,
89-
args.log_dir,
90-
args.log_level,
91-
args.log_max_files,
92-
None,
93-
None,
94-
None,
95-
None,
96-
None,
97-
false,
98-
args.console,
99-
);
73+
let _guards = init_command_tracing(args.log_level, args.console);
10074

10175
// Load config.
10276
let config = dfinit::Config::load(&args.config).inspect_err(|err| {

dragonfly-client/src/bin/dfcache/export.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,6 @@ pub struct ExportCommand {
109109
)]
110110
log_level: Level,
111111

112-
#[arg(
113-
long,
114-
default_value_os_t = dfcache::default_dfcache_log_dir(),
115-
help = "Specify the log directory"
116-
)]
117-
log_dir: PathBuf,
118-
119-
#[arg(
120-
long,
121-
default_value_t = 6,
122-
help = "Specify the max number of log files"
123-
)]
124-
log_max_files: usize,
125-
126112
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
127113
console: bool,
128114
}
@@ -141,19 +127,7 @@ impl ExportCommand {
141127
Args::parse();
142128

143129
// Initialize tracing.
144-
let _guards = init_tracing(
145-
dfcache::NAME,
146-
self.log_dir.clone(),
147-
self.log_level,
148-
self.log_max_files,
149-
None,
150-
None,
151-
None,
152-
None,
153-
None,
154-
false,
155-
self.console,
156-
);
130+
let _guards = init_command_tracing(self.log_level, self.console);
157131

158132
// Validate the command line arguments.
159133
if let Err(err) = self.validate_args() {

dragonfly-client/src/bin/dfcache/import.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,6 @@ pub struct ImportCommand {
108108
)]
109109
log_level: Level,
110110

111-
#[arg(
112-
long,
113-
default_value_os_t = dfcache::default_dfcache_log_dir(),
114-
help = "Specify the log directory"
115-
)]
116-
log_dir: PathBuf,
117-
118-
#[arg(
119-
long,
120-
default_value_t = 6,
121-
help = "Specify the max number of log files"
122-
)]
123-
log_max_files: usize,
124-
125111
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
126112
console: bool,
127113
}
@@ -140,19 +126,7 @@ impl ImportCommand {
140126
Args::parse();
141127

142128
// Initialize tracing.
143-
let _guards = init_tracing(
144-
dfcache::NAME,
145-
self.log_dir.clone(),
146-
self.log_level,
147-
self.log_max_files,
148-
None,
149-
None,
150-
None,
151-
None,
152-
None,
153-
false,
154-
self.console,
155-
);
129+
let _guards = init_command_tracing(self.log_level, self.console);
156130

157131
// Validate the command line arguments.
158132
if let Err(err) = self.validate_args() {

dragonfly-client/src/bin/dfcache/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use clap::{Parser, Subcommand};
1818
use dragonfly_client::grpc::dfdaemon_download::DfdaemonDownloadClient;
1919
use dragonfly_client::grpc::health::HealthClient;
20-
use dragonfly_client::tracing::init_tracing;
20+
use dragonfly_client::tracing::init_command_tracing;
2121
use dragonfly_client_config::VersionValueParser;
2222
use dragonfly_client_config::{dfcache, dfdaemon};
2323
use dragonfly_client_core::Result;

dragonfly-client/src/bin/dfcache/stat.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,6 @@ pub struct StatCommand {
5555
)]
5656
log_level: Level,
5757

58-
#[arg(
59-
long,
60-
default_value_os_t = dfcache::default_dfcache_log_dir(),
61-
help = "Specify the log directory"
62-
)]
63-
log_dir: PathBuf,
64-
65-
#[arg(
66-
long,
67-
default_value_t = 6,
68-
help = "Specify the max number of log files"
69-
)]
70-
log_max_files: usize,
71-
7258
#[arg(long, default_value_t = false, help = "Specify whether to print log")]
7359
console: bool,
7460
}
@@ -87,19 +73,7 @@ impl StatCommand {
8773
Args::parse();
8874

8975
// Initialize tracing.
90-
let _guards = init_tracing(
91-
dfcache::NAME,
92-
self.log_dir.clone(),
93-
self.log_level,
94-
self.log_max_files,
95-
None,
96-
None,
97-
None,
98-
None,
99-
None,
100-
false,
101-
self.console,
102-
);
76+
let _guards = init_command_tracing(self.log_level, self.console);
10377

10478
// Get dfdaemon download client.
10579
let dfdaemon_download_client =

0 commit comments

Comments
 (0)