From 5e90ab0961af4ae126315ecf278fefd6df9058ba Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Fri, 13 Aug 2021 23:37:35 +0200 Subject: [PATCH 1/5] Add utility method to print a helpful startup message --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 714f9f82a..6b99efd2e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,7 @@ pub mod product_config_utils; pub mod reconcile; pub mod role_utils; pub mod status; +pub mod utils; pub mod validation; pub use crate::crd::CustomResourceExt; From dc0ecb9f7cfe2e4efaa8dd23ea3be377f0b40e04 Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Fri, 13 Aug 2021 23:38:34 +0200 Subject: [PATCH 2/5] Add utility method to print a helpful startup message --- src/utils.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/utils.rs diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 000000000..3d3b238ee --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,18 @@ +pub fn print_startup_string( + pkg_description: &str, + pkg_version: &str, + git_version: Option<&str>, + target: &str, + built_time: &str, + rustc_version: &str, +) { + let git_information = match git_version { + None => "".to_string(), + Some(git) => format!(" (Git information: {})", git), + }; + info!("Starting {}", pkg_description); + info!( + "This is version {}{}, built for {} by {} at {}", + pkg_version, git_information, target, rustc_version, built_time + ) +} From c5364ca4d4ae750e9fcc9f8f64175b83c72abc15 Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Fri, 13 Aug 2021 23:40:06 +0200 Subject: [PATCH 3/5] Missing import --- src/utils.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index 3d3b238ee..6377959a6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,3 +1,5 @@ +use tracing::info; + pub fn print_startup_string( pkg_description: &str, pkg_version: &str, From 3251f7585d20096730ef40feb5f7cf6e425c08ae Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Fri, 13 Aug 2021 23:55:49 +0200 Subject: [PATCH 4/5] documentation --- src/utils.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index 6377959a6..57464622b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,32 @@ use tracing::info; +/// Prints helpful and standardized diagnostic messages. +/// +/// This method is meant to be called first thing in the `main` method of an Operator. +/// +/// # Usage +/// +/// Use the [`built`](https://crates.io/crates/built) crate and include it in your `main.rs` like this: +/// +/// ```ignore +/// mod built_info { +/// // The file has been placed there by the build script. +/// include!(concat!(env!("OUT_DIR"), "/built.rs")); +/// } +/// ``` +/// +/// Then call this method in your `main` method: +/// +/// ```ignore +/// stackable_operator::utils::print_startup_string( +/// built_info::PKG_DESCRIPTION, +/// built_info::PKG_VERSION, +/// built_info::GIT_VERSION, +/// built_info::TARGET, +/// built_info::BUILT_TIME_UTC, +/// built_info::RUSTC_VERSION, +/// ); +/// ``` pub fn print_startup_string( pkg_description: &str, pkg_version: &str, From 0d033b975ceac68e5843f58163790557489a95f6 Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Sat, 14 Aug 2021 00:01:08 +0200 Subject: [PATCH 5/5] documentation --- src/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 57464622b..227d17873 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -8,7 +8,7 @@ use tracing::info; /// /// Use the [`built`](https://crates.io/crates/built) crate and include it in your `main.rs` like this: /// -/// ```ignore +/// ```text /// mod built_info { /// // The file has been placed there by the build script. /// include!(concat!(env!("OUT_DIR"), "/built.rs")); @@ -17,7 +17,7 @@ use tracing::info; /// /// Then call this method in your `main` method: /// -/// ```ignore +/// ```text /// stackable_operator::utils::print_startup_string( /// built_info::PKG_DESCRIPTION, /// built_info::PKG_VERSION,