diff --git a/clients/native/src/main.rs b/clients/native/src/main.rs index edb7c56f1a..f8fd2df71b 100644 --- a/clients/native/src/main.rs +++ b/clients/native/src/main.rs @@ -3,7 +3,7 @@ use std::error::Error; -use clap::{crate_version, Parser}; +use clap::{crate_name, crate_version, Parser}; use logging::setup_logging; use network_defaults::setup_env; @@ -15,26 +15,9 @@ pub mod websocket; #[tokio::main] async fn main() -> Result<(), Box> { setup_logging(); - println!("{}", banner()); + println!("{}", logging::banner(crate_name!(), crate_version!())); let args = commands::Cli::parse(); setup_env(args.config_env_file.as_ref()); commands::execute(&args).await } - -fn banner() -> String { - format!( - r#" - - _ __ _ _ _ __ ___ - | '_ \| | | | '_ \ _ \ - | | | | |_| | | | | | | - |_| |_|\__, |_| |_| |_| - |___/ - - (client - version {:}) - - "#, - crate_version!() - ) -} diff --git a/clients/socks5/src/main.rs b/clients/socks5/src/main.rs index 6dcd9183ab..9c8fcdb87a 100644 --- a/clients/socks5/src/main.rs +++ b/clients/socks5/src/main.rs @@ -3,7 +3,7 @@ use std::error::Error; -use clap::{crate_version, Parser}; +use clap::{crate_name, crate_version, Parser}; use logging::setup_logging; use network_defaults::setup_env; @@ -15,26 +15,9 @@ pub mod socks; #[tokio::main] async fn main() -> Result<(), Box> { setup_logging(); - println!("{}", banner()); + println!("{}", logging::banner(crate_name!(), crate_version!())); let args = commands::Cli::parse(); setup_env(args.config_env_file.as_ref()); commands::execute(&args).await } - -fn banner() -> String { - format!( - r#" - - _ __ _ _ _ __ ___ - | '_ \| | | | '_ \ _ \ - | | | | |_| | | | | | | - |_| |_|\__, |_| |_| |_| - |___/ - - (socks5 proxy - version {:}) - - "#, - crate_version!() - ) -} diff --git a/common/logging/Cargo.toml b/common/logging/Cargo.toml index 14d2e3a737..c0e2159864 100644 --- a/common/logging/Cargo.toml +++ b/common/logging/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" [dependencies] log = "0.4.0" -pretty_env_logger = "0.4.0" \ No newline at end of file +pretty_env_logger = "0.4.0" diff --git a/common/logging/src/lib.rs b/common/logging/src/lib.rs index 6c026e9b90..9ab981e6ac 100644 --- a/common/logging/src/lib.rs +++ b/common/logging/src/lib.rs @@ -23,3 +23,20 @@ pub fn setup_logging() { .filter_module("sled", log::LevelFilter::Warn) .init(); } + +pub fn banner(crate_name: &str, crate_version: &str) -> String { + format!( + r#" + + _ __ _ _ _ __ ___ + | '_ \| | | | '_ \ _ \ + | | | | |_| | | | | | | + |_| |_|\__, |_| |_| |_| + |___/ + + ({:} - version {:}) + + "#, + crate_name, crate_version + ) +} diff --git a/gateway/src/main.rs b/gateway/src/main.rs index 58577d03c0..bb7740fb72 100644 --- a/gateway/src/main.rs +++ b/gateway/src/main.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use build_information::BinaryBuildInformation; -use clap::{crate_version, Parser, ValueEnum}; +use clap::{crate_name, crate_version, Parser, ValueEnum}; use colored::Colorize; use lazy_static::lazy_static; use log::error; @@ -66,7 +66,7 @@ impl Cli { async fn main() -> Result<(), Box> { setup_logging(); if atty::is(atty::Stream::Stdout) { - println!("{}", banner()); + println!("{}", logging::banner(crate_name!(), crate_version!())); } let args = Cli::parse(); @@ -82,23 +82,6 @@ async fn main() -> Result<(), Box> { }) } -fn banner() -> String { - format!( - r#" - - _ __ _ _ _ __ ___ - | '_ \| | | | '_ \ _ \ - | | | | |_| | | | | | | - |_| |_|\__, |_| |_| |_| - |___/ - - (gateway - version {:}) - - "#, - crate_version!() - ) -} - #[cfg(test)] mod tests { use super::*; diff --git a/mixnode/src/main.rs b/mixnode/src/main.rs index 11e06b8569..adb9556530 100644 --- a/mixnode/src/main.rs +++ b/mixnode/src/main.rs @@ -6,7 +6,7 @@ extern crate rocket; use ::config::defaults::setup_env; use build_information::BinaryBuildInformation; -use clap::{crate_version, Parser, ValueEnum}; +use clap::{crate_name, crate_version, Parser, ValueEnum}; use lazy_static::lazy_static; use logging::setup_logging; @@ -64,7 +64,7 @@ impl Cli { async fn main() { setup_logging(); if atty::is(atty::Stream::Stdout) { - println!("{}", banner()); + println!("{}", logging::banner(crate_name!(), crate_version!())); } let args = Cli::parse(); @@ -72,23 +72,6 @@ async fn main() { commands::execute(args).await; } -fn banner() -> String { - format!( - r#" - - _ __ _ _ _ __ ___ - | '_ \| | | | '_ \ _ \ - | | | | |_| | | | | | | - |_| |_|\__, |_| |_| |_| - |___/ - - (mixnode - version {:}) - - "#, - crate_version!() - ) -} - #[cfg(test)] mod tests { use super::*;