diff --git a/Cargo.toml b/Cargo.toml index ff15703..f718e6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "freighter-registry" -version = "0.3.0" +version = "0.4.0" edition = "2021" license = "MIT" homepage = "https://github.com/open-rust-Initiative/freighter" @@ -10,31 +10,31 @@ description = "The Freighter's purpose is to help the community and company to b # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.71" -thiserror = "1.0.36" -clap = "4.3.4" +anyhow = "1.0.79" +thiserror = "1.0.56" +clap = {version = "4.4.13", features = ["cargo"]} git2 = "0.18.1" git2-curl = "0.19" -url = "2.3.1" -serde = { version = "1.0.164", features = ["derive"] } -serde_json = "1.0.97" -walkdir = "2.3.2" +url = "2.5.0" +serde = { version = "1.0.195", features = ["derive"] } +serde_json = "1.0.111" +walkdir = "2.4.0" reqwest = { version = "0.11.13", features = ["blocking"] } -openssl = { version = "0.10.54", features = ["vendored"] } -chrono = "0.4.26" -sha2 = "0.10.7" -dirs = "5.0.0" +openssl = { version = "0.10.62", features = ["vendored"] } +chrono = "0.4.31" +sha2 = "0.10.8" +dirs = "5.0.1" toml = "0.8.8" log4rs = {version = "1.2.0", features = ["toml_format"] } -tokio = { version = "1.28.2", features = ["full"] } -warp = { version = "0.3.3", features = ["tls"] } -tokio-util = { version = "0.7.4", features = ["codec"] } -tracing = "0.1" -tracing-subscriber = "0.3.17" -bytes = "1.1.0" -async-trait = "0.1.64" -tokio-test = "0.4.2" -rayon = "1.7.0" +tokio = { version = "1.35.1", features = ["macros", "process"] } +warp = { version = "0.3.6", features = ["tls"] } +tokio-util = { version = "0.7.10", features = ["codec"] } +tracing = "0.1.40" +tracing-subscriber = "0.3.18" +bytes = "1.5.0" +async-trait = "0.1.77" +tokio-test = "0.4.3" +rayon = "1.8.0" [dev-dependencies] diff --git a/README.md b/README.md index 380e746..eb58e42 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,18 @@ Freighter's functionality mainly consists of four parts: synchronizing crates in Freighter can be executed as a standalone executable program. You can build it using the **cargo build --release** command and then copy it to your `/usr/local/bin directory`. -#### 1. Synchronizing Crates Index and Crates +#### 1. Prerequisite +* Freighter defaults to storing data in the **default directory /Users/${USERNAME}/freighter**. To customize the storage directory, modify the config.toml file. +* The config file can be obtained by executing any command; Freighter copies the config.default.toml file to the default directory. +* Alternatively, the config file can be manually copied from the source code directory src which named **config.default.toml**. +* Customize the storage path for data by modifying configurations like **log_path, index_path, crates_path**, etc., in the config file. +* Freighter uses the config.toml configuration in the default directory for its operations. To use a custom config path, add the -c parameter when executing a command. For example: + ```bash + freighter -c /path/to/config.toml + ``` + You can specify paths like /tmp/freighter/config.toml, /tmp/freighter, or /tmp, and Freighter will automatically interpret them as /tmp/freighter/config.toml. + +#### 2. Synchronizing Crates Index and Crates To sync crate files, Freighter needs to first sync the crates index. You can use the following command to sync the index file: ```bash @@ -30,27 +41,22 @@ freighter crates pull ``` This command will create a crates.io-index directory in the default path **/Users/${USERNAME}/freighter** and fetch the index. If the index already exists, it will attempt to update it. -You can also use the **-c** parameter to specify a **working directory** to change the storage location of the index and crates: - -```bash -freighter -c /path/to/wokring_dir crates pull -``` **Full download**: Next, you can use the download command with the init parameter to download the full set of crates files: ```bash -freighter -c /path/to/wokring_dir crates download --init +freighter crates download --init ``` **Incremental update**: Without the init parameter, Freighter will compare log records in the **working directory** to determine the index and crates that need incremental updates: ```bash -freighter -c /path/to/wokring_dir crates download +freighter crates download ``` -#### 2.Syncing the rustup-init Files -#### 3.Syncing the Rust Toolchain Files -#### 4.Http Server +#### 3.Syncing the rustup-init Files +#### 4.Syncing the Rust Toolchain Files +#### 5.Http Server ### How to contribute? diff --git a/src/cli.rs b/src/cli.rs index 203d9a2..1d5d788 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -13,10 +13,10 @@ //! ``` //! -use std::path::PathBuf; +use std::path::{PathBuf, Path}; use std::str::FromStr; -use clap::{arg, ArgMatches}; +use clap::{arg, crate_version, ArgMatches}; use log4rs::append::console::ConsoleAppender; use log4rs::append::rolling_file::policy::compound::roll::delete::DeleteRoller; use log4rs::append::rolling_file::policy::compound::trigger::size::SizeTrigger; @@ -28,7 +28,7 @@ use log4rs::config::{Appender, Root}; use log4rs::encode::pattern::PatternEncoder; use tracing::log::LevelFilter; -use crate::commands; +use crate::commands::{self}; use crate::config::{Config, LogConfig}; use crate::errors::{FreightResult, FreighterError}; @@ -47,11 +47,8 @@ pub fn main(config: &mut Config) -> FreightResult { let args = cli().try_get_matches().unwrap_or_else(|e| e.exit()); - let root = match args.get_one::("work-dir").cloned() { - Some(root) => PathBuf::from(root), - None => dirs::home_dir().unwrap(), - }; - let mut config = config.load(&root); + let config_parent = args.get_one::("config-path").cloned().map(PathBuf::from); + let mut config = config.load(config_parent); let (cmd, subcommand_args) = match args.subcommand() { Some((cmd, args)) => (cmd, args), @@ -71,13 +68,12 @@ fn cli() -> App { let usage = "freighter [SUBCOMMAND]"; App::new("freighter") - .version("0.1.0") + .version(crate_version!()) .disable_colored_help(true) .disable_help_subcommand(true) .override_usage(usage) .author("Open Rust Initiative") - .arg(arg!(-c --"work-dir" "specify the work dir, - where to download crates, rust toolchains and storage logs, default: $HOME/.freighter") + .arg(arg!(-c --"config-path" "specify the config path, default: $HOME/freighter/config.toml") ) .help_template( "\ @@ -107,9 +103,10 @@ pub fn execute_subcommand(config: &mut Config, cmd: &str, args: &ArgMatches) -> } } /// read values(log format encoder, log limit and level) from config file -/// and then initialize config for log4rs, log will preserve in /work_dir/log by default -pub fn init_log(config: &LogConfig, work_dir: PathBuf, sub_command: &str) -> FreightResult { - let binding = work_dir.join(format!("log/{}.log", sub_command)); +/// and then initialize config for log4rs, log will preserve in /log_path/log by default +pub fn init_log(config: &LogConfig, log_path: &Path, sub_command: &str) -> FreightResult { + // attach file name + let binding = log_path.join(format!("{}.log", sub_command)); let log_path = binding.to_str().unwrap(); let level = LevelFilter::from_str(&config.level).unwrap(); diff --git a/src/commands/channel.rs b/src/commands/channel.rs index e00a8d4..cce515b 100644 --- a/src/commands/channel.rs +++ b/src/commands/channel.rs @@ -107,17 +107,12 @@ with 64 download threads and then clean historical files /// /// pub fn exec(config: &mut Config, args: &ArgMatches) -> FreightResult { - let work_dir = config - .work_dir - .as_ref() - .expect("something bad happened because work_dir is none"); - - crate::cli::init_log(&config.log, work_dir.to_path_buf(), "channel").unwrap(); + crate::cli::init_log(&config.log, &config.log_path, "channel").unwrap(); let mut opts = ChannelOptions { config: config.rustup.to_owned(), proxy: config.proxy.to_owned(), - dist_path: work_dir.join("dist"), + dist_path: config.dist_path.to_owned(), ..Default::default() }; diff --git a/src/commands/command_prelude.rs b/src/commands/command_prelude.rs index f39e52b..f34e05c 100644 --- a/src/commands/command_prelude.rs +++ b/src/commands/command_prelude.rs @@ -4,7 +4,7 @@ //! //! use clap::Command; -pub use clap::{value_parser, Arg, ArgAction, ArgMatches}; +pub use clap::{value_parser, Arg, ArgAction}; /// Add a custom flag to subcommand pub fn flag(name: &'static str, help: &'static str) -> Arg { diff --git a/src/commands/crates.rs b/src/commands/crates.rs index 2397c8c..4f0650b 100644 --- a/src/commands/crates.rs +++ b/src/commands/crates.rs @@ -101,17 +101,17 @@ OPTIONS: {options} EXAMPLES -1. Sync the crates index with specify directory +1. Sync the crates index with specify config path - freighter -c /mnt/volume_fra1_01 crates pull + freighter -c /mnt/freighter/config.toml crates pull 2. Download all crates file and unload: freighter crates download --init --upload --bucket crates -3. Download crates file with multi-thread to specify directory: +3. Download crates file with multi-thread: - freighter -c /mnt/volume_fra1_01 crates -t 32 download --init + freighter crates -t 32 download --init \n") } @@ -120,20 +120,15 @@ EXAMPLES /// /// pub fn exec(config: &mut Config, args: &ArgMatches) -> FreightResult { - let work_dir = config - .work_dir - .as_ref() - .expect("something bad happened because work_dir is none"); - - crate::cli::init_log(&config.log, work_dir.to_path_buf(), "crates").unwrap(); + crate::cli::init_log(&config.log, &config.log_path, "crates").unwrap(); let opts = &mut CratesOptions { config: config.crates.to_owned(), proxy: config.proxy.to_owned(), - index: CrateIndex::new(&config.crates.index_domain, work_dir.to_owned()), + index: CrateIndex::new(&config.crates.index_domain, config.index_path.to_owned()), no_progressbar: args.get_flag("no-progressbar"), - crates_path: work_dir.join("crates"), - log_path: work_dir.join("log"), + crates_path: config.crates_path.to_owned(), + log_path: config.log_path.to_owned(), ..Default::default() }; let domain = args.get_one::("domain").cloned(); diff --git a/src/commands/rustup_init.rs b/src/commands/rustup_init.rs index 88ee38e..ffffeb7 100644 --- a/src/commands/rustup_init.rs +++ b/src/commands/rustup_init.rs @@ -84,17 +84,12 @@ with 64 download threads /// /// pub fn exec(config: &mut Config, args: &ArgMatches) -> FreightResult { - let work_dir = config - .work_dir - .as_ref() - .expect("something bad happened because work_dir is none"); - - crate::cli::init_log(&config.log, work_dir.to_path_buf(), "rustup").unwrap(); + crate::cli::init_log(&config.log, &config.log_path, "rustup").unwrap(); let mut opts = RustUpOptions { proxy: config.proxy.to_owned(), config: config.rustup.to_owned(), - rustup_path: work_dir.join("rustup"), + rustup_path: config.rustup_path.to_owned(), ..Default::default() }; diff --git a/src/config.default.toml b/src/config.default.toml index fc7b942..fea08e0 100644 --- a/src/config.default.toml +++ b/src/config.default.toml @@ -1,6 +1,9 @@ [log] +# The path which log file is saved +log_path = "" + # log format encoder, see https://docs.rs/log4rs/1.2.0/log4rs/append/file/struct.FileAppenderDeserializer.html#configuration # for more information encoder = "{d}:{l} - {m}{n}" @@ -8,11 +11,17 @@ encoder = "{d}:{l} - {m}{n}" # log level level = "info" -# will delete and regenerate log file if exceeded the limit, unit is MB +# log file will be deleted and regenerated if exceeded the threshold, unit is MB limit = 100 [crates] +# The path which the crates index file is saved +index_path = "" + +# The path which the crates file is saved +crates_path = "" + # download index from domain index_domain = "https://github.com/rust-lang/crates.io-index.git" @@ -22,9 +31,8 @@ domain = "https://static.crates.io/crates" # Number of crates download threads download_threads = 16 -# A list of domains that provide service in order -# localhost means read from filesystem -# It is better to add s3 domain at the first line +# When providing services, freighter will retrieve files from the specified location in the following sequence and +# return them to the requesting client. localhost means read from local filesystem serve_domains = [ "https://rust-proxy.obs.cn-east-3.myhuaweicloud.com", # "localhost", @@ -36,13 +44,19 @@ serve_domains = [ serve_index = "/opt/rust/" [rustup] -# download rustup from domain +# The path which the rustup file is saved +rustup_path = "" + +# The path which the rustup release sha file is saved +dist_path = "" + +# which domain to download rustup from domain = "https://static.rust-lang.org" # Number of rust toolchain download threads download_threads = 16 -# stable versions that you want to sync with +# released rust versions that you want to sync with sync_stable_versions = [ "1.9", "1.10", @@ -132,7 +146,15 @@ sync_stable_versions = [ "1.68.1", "1.68.2", "1.69", - "1.70" + "1.70", + "1.71", + "1.71.1", + "1.72", + "1.72.1", + "1.73", + "1.74", + "1.74.1", + "1.75", ] # days you want to keep for historical nightly version @@ -141,8 +163,8 @@ sync_nightly_days = 30 # days you want to keep for historical beta version sync_beta_days = 30 -# A list of domains that provide service in order -# localhost means read from filesystem +# When providing services, freighter will retrieve files from the specified location in the following sequence and +# return them to the requesting client. localhost means read from local filesystem serve_domains = [ "https://rust-proxy.obs.cn-east-3.myhuaweicloud.com", # "localhost", diff --git a/src/config.rs b/src/config.rs index b6e53ba..2f35500 100644 --- a/src/config.rs +++ b/src/config.rs @@ -14,7 +14,17 @@ use std::{ /// parse config from file #[derive(Serialize, Deserialize, Debug, Default, Clone)] pub struct Config { - pub work_dir: Option, + #[serde(default = "default_value_for_path")] + pub index_path: PathBuf, + #[serde(default = "default_value_for_path")] + pub crates_path: PathBuf, + #[serde(default = "default_value_for_path")] + pub log_path: PathBuf, + #[serde(default = "default_value_for_path")] + pub rustup_path: PathBuf, + #[serde(default = "default_value_for_path")] + pub dist_path: PathBuf, + pub crates: CratesConfig, pub rustup: RustUpConfig, pub log: LogConfig, @@ -23,6 +33,8 @@ pub struct Config { #[derive(Serialize, Deserialize, Debug, Default, Clone)] pub struct LogConfig { + #[serde(deserialize_with = "path_option_from_str")] + pub log_path: Option, pub encoder: String, pub level: String, pub limit: u64, @@ -30,6 +42,10 @@ pub struct LogConfig { #[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct CratesConfig { + #[serde(deserialize_with = "path_option_from_str")] + pub index_path: Option, + #[serde(deserialize_with = "path_option_from_str")] + pub crates_path: Option, pub index_domain: String, pub domain: String, pub download_threads: usize, @@ -40,6 +56,10 @@ pub struct CratesConfig { /// config for rustup mirror sync #[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct RustUpConfig { + #[serde(deserialize_with = "path_option_from_str")] + pub rustup_path: Option, + #[serde(deserialize_with = "path_option_from_str")] + pub dist_path: Option, pub domain: String, pub download_threads: usize, pub sync_stable_versions: Vec, @@ -56,11 +76,32 @@ pub struct ProxyConfig { pub download_proxy: String, } +// deserialize a string from a TOML file into an Option +fn path_option_from_str<'de, D>(deserializer: D) -> Result, D::Error> +where + D: serde::Deserializer<'de>, +{ + let s: String = Deserialize::deserialize(deserializer)?; + Ok(if s.is_empty() { + None + } else { + Some(Path::new(&s).to_path_buf()) + }) +} + +fn default_value_for_path() -> PathBuf { + PathBuf::new() +} + /// impl Config { pub fn new() -> Config { Config { - work_dir: None, + index_path: PathBuf::new(), + crates_path: PathBuf::new(), + log_path: PathBuf::new(), + rustup_path: PathBuf::new(), + dist_path: PathBuf::new(), rustup: RustUpConfig::default(), crates: CratesConfig::default(), log: LogConfig::default(), @@ -68,19 +109,20 @@ impl Config { } } - pub fn format_path(root: &Path) -> PathBuf { - root.join("freighter/config.toml") - } + pub fn load(&self, config_parent: Option) -> Config { + let config_path = format_path(&config_parent, "config.toml"); + let mut config = Self::read_config_or_init(&config_path); - pub fn load(&self, root: &Path) -> Config { - let config_path = Self::format_path(root); - let mut config = Self::get_config(&config_path); - config.work_dir = Some(root.join("freighter")); + config.index_path = format_path(&config.crates.index_path, "crates.io-index"); + config.crates_path = format_path(&config.crates.crates_path, "crates"); + config.log_path = format_path(&config.log.log_path, "log"); + config.rustup_path = format_path(&config.rustup.rustup_path, "rustup"); + config.dist_path = format_path(&config.rustup.dist_path, "dist"); config } - // read from config file, config file will be created by default if not exist - pub fn get_config(config_path: &Path) -> Config { + // read from config file, default config file will be created if not exist + pub fn read_config_or_init(config_path: &Path) -> Config { let content = match fs::read_to_string(config_path) { Ok(content) => content, Err(err) => match err.kind() { @@ -90,6 +132,7 @@ impl Config { fs::create_dir_all(parent).unwrap(); } } + //rewrite config.default.toml under config_path fs::write(config_path, include_str!("config.default.toml")).unwrap(); fs::read_to_string(config_path).unwrap() } @@ -104,3 +147,39 @@ impl Config { } } } + +pub fn format_path(config_path: &Option, name: &str) -> PathBuf { + let default_dir = dirs::home_dir().unwrap().join("freighter"); + let path = match config_path { + Some(path) => path, + None => &default_dir, + }; + let path_str = path.to_str().unwrap(); + if !path_str.contains("freighter") { + return path.join("freighter").join(name); + } else if !path_str.contains(name) { + return path.join(name); + } + path.to_path_buf() +} + +#[cfg(test)] +mod tests { + use std::path::PathBuf; + + use crate::config::format_path; + + #[test] + fn test_format_path() { + // test config path + let default = dirs::home_dir().unwrap(); + assert_eq!(format_path(&None, "config.toml"), default.join("freighter/config.toml")); + assert_eq!(format_path(&Some("/tmp".into()), "config.toml"), PathBuf::from("/tmp/freighter/config.toml")); + + // test index path + assert_eq!(format_path(&None, "index"), default.join("freighter/index")); + assert_eq!(format_path(&Some("/tmp".into()), "index"), PathBuf::from("/tmp/freighter/index")); + assert_eq!(format_path(&Some("/tmp/freighter".into()), "index"), PathBuf::from("/tmp/freighter/index")); + assert_eq!(format_path(&Some("/tmp/freighter/index".into()), "index"), PathBuf::from("/tmp/freighter/index")); + } +} diff --git a/src/handler/channel.rs b/src/handler/channel.rs index 6dfd642..5622328 100644 --- a/src/handler/channel.rs +++ b/src/handler/channel.rs @@ -117,7 +117,7 @@ pub fn sync_rust_toolchain(opts: &ChannelOptions) -> FreightResult { let today = Utc::now().date_naive(); if today >= start_date { let duration_days = (today - start_date).num_days().try_into().unwrap(); - for (_, day) in start_date.iter_days().take(duration_days).enumerate() { + for day in start_date.iter_days().take(duration_days) { sync_channel(opts, &format!("beta-{}", day))?; sync_channel(opts, &format!("nightly-{}", day))?; } diff --git a/src/handler/index.rs b/src/handler/index.rs index 25ed73a..133e144 100644 --- a/src/handler/index.rs +++ b/src/handler/index.rs @@ -52,7 +52,7 @@ impl Default for CrateIndex { let home_path = dirs::home_dir().unwrap(); CrateIndex { url: Url::parse("https://github.com/rust-lang/crates.io-index.git").unwrap(), - path: home_path.join("crates.io-index"), + path: home_path.join("freighter/crates.io-index"), } } } @@ -66,9 +66,9 @@ impl CrateIndex { // use default name origin const REMOTE_NAME: &'static str = "origin"; /// Create a new `CrateIndex` from a `Work dir`. - pub fn new(domain: &str, work_dir: PathBuf) -> Self { + pub fn new(domain: &str, path: PathBuf) -> Self { Self { - path: work_dir.join("crates.io-index"), + path, url: Url::parse(domain).unwrap(), } } @@ -513,7 +513,7 @@ mod tests { let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); path.push("data/tests/fixtures/"); - let index = + let _ = super::CrateIndex::new("https://github.com/rust-lang/crates.io-index.git", path); // index.git_clone(&mut CratesOptions::default()).unwrap(); } @@ -523,7 +523,7 @@ mod tests { let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); path.push("data/tests/fixtures/"); - let index = + let _ = super::CrateIndex::new("https://github.com/rust-lang/crates.io-index.git", path); } } diff --git a/src/server/file_server.rs b/src/server/file_server.rs index 41bf06e..670ffaa 100644 --- a/src/server/file_server.rs +++ b/src/server/file_server.rs @@ -86,17 +86,11 @@ mod filters { pub fn build_route( config: Config, ) -> impl Filter + Clone { - let git_work_dir = if let Some(path) = &config.crates.serve_index { - PathBuf::from(path) - } else { - config.work_dir.clone().unwrap() - }; - // GET /dist/... => ./dist/.. dist(config.clone()) .or(rustup(config.clone())) .or(crates(config.clone())) - .or(git(git_work_dir)) + .or(git(config.clone())) .or(publish(config.clone())) .or(sparse_index(config)) } @@ -121,13 +115,12 @@ mod filters { match parse_result { Ok(result) => { println!("JSON: {:?}", result); - let work_dir = config.work_dir.unwrap(); utils::save_crate_index( &result, &file_content, - work_dir.join("crates.io-index"), + config.index_path, ); - utils::save_crate_file(&result, &file_content, work_dir.join("crates")); + utils::save_crate_file(&result, &file_content, config.crates_path); // let std::fs::write(); // 1.verify name and version from local db // 2.call remote server to check info in crates.io @@ -147,7 +140,7 @@ mod filters { .and_then(|tail: warp::path::Tail, config: Config| async move { handlers::return_files( config.rustup.serve_domains.unwrap(), - config.work_dir.unwrap(), + config.index_path, PathBuf::from("crates.io-index").join(tail.as_str()), false, ) @@ -165,7 +158,7 @@ mod filters { .and_then(|tail: warp::path::Tail, config: Config| async move { handlers::return_files( config.rustup.serve_domains.unwrap(), - config.work_dir.unwrap(), + config.dist_path, PathBuf::from("dist").join(tail.as_str()), false, ) @@ -184,7 +177,7 @@ mod filters { .and_then(move |tail: warp::path::Tail, config: Config| async move { handlers::return_files( config.rustup.serve_domains.unwrap(), - config.work_dir.unwrap(), + config.rustup_path, PathBuf::from("rustup").join(tail.as_str()), false, ) @@ -218,7 +211,7 @@ mod filters { .join(format!("{}-{}.crate", name, version)); handlers::return_files( config.crates.serve_domains.unwrap(), - config.work_dir.unwrap(), + config.crates_path, file_path, true, ) @@ -229,8 +222,15 @@ mod filters { // build '/crate.io-index/(git protocol)' route, this route handle gti clone and git pull request pub fn git( - git_work_dir: PathBuf, + // git_work_dir: PathBuf, + config: Config, ) -> impl Filter + Clone { + let git_work_dir = if let Some(path) = &config.crates.serve_index { + PathBuf::from(path) + } else { + config.index_path + }; + let git_upload_pack = warp::path!("git-upload-pack") .and(warp::path::tail()) .and(warp::method()) diff --git a/src/server/git_protocol.rs b/src/server/git_protocol.rs index 46c0439..447b62d 100644 --- a/src/server/git_protocol.rs +++ b/src/server/git_protocol.rs @@ -147,13 +147,14 @@ async fn send( loop { let mut bytes_out = BytesMut::new(); - git_output.read_buf(&mut bytes_out).await?; + let res = git_output.read_buf(&mut bytes_out).await; + tracing::info!("reading output :{:?}", res); if bytes_out.is_empty() { - println!("send:empty"); + tracing::info!("send:empty"); return Ok(()); } if add_refs { - println!("send: bytes_out: {:?}", bytes_out.clone().freeze()); + tracing::info!("send: bytes_out: {:?}", bytes_out.clone().freeze()); } sender.send_data(bytes_out.freeze()).await.unwrap(); }