Skip to content

Commit

Permalink
Add version in logs and admin space
Browse files Browse the repository at this point in the history
  • Loading branch information
JEnoch committed Dec 21, 2020
1 parent 2565262 commit 77f4e1f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
11 changes: 5 additions & 6 deletions Cargo.toml
Expand Up @@ -29,18 +29,17 @@ crate-type = ["cdylib"]
zenoh_backend_traits = { git = "https://github.com/eclipse-zenoh/zenoh.git" }
zenoh = { git = "https://github.com/eclipse-zenoh/zenoh.git" }
zenoh-util = { git = "https://github.com/eclipse-zenoh/zenoh.git" }
uhlc = "0.2"
async-trait = "0.1"
async-std = { version = "=1.8.0", features = ["unstable"] }
async-trait = "0.1.38"
uhlc = "0.2.1"
lazy_static = "1.4.0"
env_logger = "0.7.1"
log = "0.4"
git-version = "0.3.4"
rocksdb = "0.15.0"


[dependencies.async-std]
version = "=1.6.5"
features = ["unstable"]
[build-dependencies]
rustc_version = "0.3"

[package.metadata.deb]
name = "zenoh-backend-rocksdb"
Expand Down
20 changes: 20 additions & 0 deletions build.rs
@@ -0,0 +1,20 @@
// Copyright (c) 2017, 2020 ADLINK Technology Inc.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ADLINK zenoh team, <zenoh@adlink-labs.tech>
//
fn main() {
// Add rustc version to zenohd
let version_meta = rustc_version::version_meta().unwrap();
println!(
"cargo:rustc-env=RUSTC_VERSION={}",
version_meta.short_version_string
);
}
7 changes: 4 additions & 3 deletions src/lib.rs
Expand Up @@ -55,12 +55,13 @@ const MAX_VAL_LEN: usize = 1 + 8 + 8 + uhlc::ID::MAX_SIZE;
// minimum size of serialized data-info: deleted (u8) + encoding (u64) + timestamp (u64 + ID at 1 byte)
const MIN_VAL_LEN: usize = 1 + 8 + 8 + uhlc::ID::MAX_SIZE;

const GIT_VERSION: &str = git_version::git_version!(prefix = "v", cargo_prefix = "v");
lazy_static::lazy_static! {
static ref LONG_VERSION: String = format!("{} built with {}", GIT_VERSION, env!("RUSTC_VERSION"));
static ref GC_PERIOD: Duration = Duration::new(5, 0);
static ref MIN_DELAY_BEFORE_REMOVAL: NTP64 = NTP64::from(Duration::new(5, 0));
}

const VERSION: &str = git_version::git_version!(prefix = "v", cargo_prefix = "v");

pub(crate) enum OnClosure {
DestroyDB,
Expand All @@ -72,7 +73,7 @@ pub fn create_backend(_unused: &Properties) -> ZResult<Box<dyn Backend>> {
// For some reasons env_logger is sometime not active in a loaded library.
// Try to activate it here, ignoring failures.
let _ = env_logger::try_init();
debug!("RocksDB backend {}", VERSION);
debug!("RocksDB backend {}", LONG_VERSION.as_str());

let root = if let Some(dir) = std::env::var_os(SCOPE_ENV_VAR) {
PathBuf::from(dir)
Expand All @@ -83,7 +84,7 @@ pub fn create_backend(_unused: &Properties) -> ZResult<Box<dyn Backend>> {
};
let mut properties = Properties::default();
properties.insert("root".into(), root.to_string_lossy().into());
properties.insert("version".into(), VERSION.into());
properties.insert("version".into(), LONG_VERSION.clone());

let admin_status = zenoh::utils::properties_to_json_value(&properties);
Ok(Box::new(RocksdbBackend { admin_status, root }))
Expand Down

0 comments on commit 77f4e1f

Please sign in to comment.