-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(tracing): replacing log and env_logger with tracing and tracing_subscriber Signed-off-by: gabrik <[email protected]> * chore(clippy): fixing clippy Signed-off-by: gabrik <[email protected]> * fix(ci): valgrind tests Signed-off-by: gabrik <[email protected]> * chore: removed log from leak tests, added explict docstrings Signed-off-by: gabrik <[email protected]> * feat(tracing): adding loki configuration by env variable, feature gated Signed-off-by: gabrik <[email protected]> * feat(tracing): adding apikey header and value configuration for loki logging Signed-off-by: gabrik <[email protected]> * feat(tracing): added init_log function that does not use the EnvFilter, thus no static leaks Signed-off-by: gabrik <[email protected]> * chore: using right functions in valgrind tests Signed-off-by: gabrik <[email protected]> --------- Signed-off-by: gabrik <[email protected]>
- Loading branch information
Showing
167 changed files
with
1,695 additions
and
1,077 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,11 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
use libloading::Library; | ||
use log::{debug, warn}; | ||
use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; | ||
use std::ffi::OsString; | ||
use std::ops::Deref; | ||
use std::path::PathBuf; | ||
use tracing::{debug, warn}; | ||
use zenoh_core::zconfigurable; | ||
use zenoh_result::{bail, ZResult}; | ||
|
||
|
@@ -111,7 +111,7 @@ impl LibLoader { | |
pub unsafe fn search_and_load(&self, name: &str) -> ZResult<(Library, PathBuf)> { | ||
let filename = format!("{}{}{}", *LIB_PREFIX, name, *LIB_SUFFIX); | ||
let filename_ostr = OsString::from(&filename); | ||
log::debug!( | ||
tracing::debug!( | ||
"Search for library {} to load in {:?}", | ||
filename, | ||
self.search_paths | ||
|
@@ -150,7 +150,7 @@ impl LibLoader { | |
prefix: Option<&str>, | ||
) -> Vec<(Library, PathBuf, String)> { | ||
let lib_prefix = format!("{}{}", *LIB_PREFIX, prefix.unwrap_or("")); | ||
log::debug!( | ||
tracing::debug!( | ||
"Search for libraries {}*{} to load in {:?}", | ||
lib_prefix, | ||
*LIB_SUFFIX, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use tracing_subscriber::EnvFilter; | ||
|
||
/// This is an utility function to enable the tracing formatting subscriber from | ||
/// the `RUST_LOG` environment variable. | ||
/// | ||
/// # Safety | ||
/// Calling this function initializes a `lazy_static` in the `tracing` crate | ||
/// such static is not deallocated prior to process existing, thus tools such as `valgrind` | ||
/// will report a memory leak. | ||
/// Refer to this issue: https://github.com/tokio-rs/tracing/issues/2069 | ||
pub fn init_log_from_env() { | ||
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("z=info")); | ||
|
||
let subscriber = tracing_subscriber::fmt() | ||
.with_env_filter(env_filter) | ||
.with_thread_ids(true) | ||
.with_thread_names(true) | ||
.with_level(true) | ||
.with_target(true); | ||
|
||
let subscriber = subscriber.finish(); | ||
let _ = tracing::subscriber::set_global_default(subscriber); | ||
} | ||
|
||
/// This is an utility function to enables the default tracing subscriber with INFO level | ||
pub fn init_log() { | ||
let subscriber = tracing_subscriber::fmt() | ||
.with_max_level(tracing::Level::INFO) | ||
.with_thread_ids(true) | ||
.with_thread_names(true) | ||
.with_level(true) | ||
.with_target(true); | ||
|
||
let subscriber = subscriber.finish(); | ||
let _ = tracing::subscriber::set_global_default(subscriber); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.