Skip to content

Commit 88565b1

Browse files
skletsundmitry-timofeev
authored andcommitted
Log app info at its start [ECR-3150] (#905)
Log info about the app version and build mode at the app's start.
1 parent 86f29ad commit 88565b1

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

exonum-java-binding/core/rust/Cargo.lock

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

exonum-java-binding/core/rust/exonum-java/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ exonum-configuration = "0.11"
1313
exonum-btc-anchoring = "0.11"
1414
exonum-time = "0.11"
1515
env_logger = "0.6.1"
16+
log = "0.4"
1617
toml = "0.4.6"
1718
serde = "1.0"
1819
serde_derive = "1.0"

exonum-java-binding/core/rust/exonum-java/src/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,39 @@ extern crate exonum_btc_anchoring;
1919
extern crate exonum_configuration;
2020
extern crate exonum_time;
2121
extern crate java_bindings;
22+
#[macro_use]
23+
extern crate log;
2224

2325
#[cfg(test)]
2426
extern crate tempfile;
2527

28+
use java_bindings::get_lib_version;
29+
2630
mod node_builder;
2731

2832
fn main() {
2933
env_logger::init();
3034
// Panic if `_JAVA_OPTIONS` environmental variable is set.
3135
java_bindings::panic_if_java_options();
3236

37+
// Log app's metadata
38+
log_app_metadata();
39+
3340
let builder = node_builder::create();
3441
builder.run()
3542
}
43+
44+
// Prints info about version and build mode of started app to the STDOUT.
45+
fn log_app_metadata() {
46+
let version = get_lib_version();
47+
let build_type = if cfg!(debug_assertions) {
48+
"debug"
49+
} else {
50+
"release"
51+
};
52+
53+
info!(
54+
"Started Exonum Java {} (built in {} mode)",
55+
version, build_type
56+
);
57+
}

exonum-java-binding/core/rust/src/runtime/library_loader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pub extern "system" fn Java_com_exonum_binding_util_LibraryLoader_nativeGetLibra
2323
env.new_string(get_lib_version()).unwrap().into_inner()
2424
}
2525

26-
// Returns the exact value of the `version` field from the library's Cargo.toml configuration file.
27-
fn get_lib_version() -> &'static str {
26+
/// Returns the exact value of the `version` field from the library's Cargo.toml configuration file.
27+
pub fn get_lib_version() -> &'static str {
2828
env!("CARGO_PKG_VERSION")
2929
}
3030

exonum-java-binding/core/rust/src/runtime/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ mod time_service;
2525

2626
pub use self::config::*;
2727
pub use self::java_service_runtime::JavaServiceRuntime;
28+
pub use self::library_loader::get_lib_version;
2829
pub use self::paths::panic_if_java_options;
2930
pub use self::service_factory_adapter::JavaServiceFactoryAdapter;

0 commit comments

Comments
 (0)