Commit 183790b5 authored by RILLING Louis's avatar RILLING Louis
Browse files

tansiv-client: Make use-own-logger feature compatible with multiple contexts in a same process

parent 97513620
Pipeline #179535 failed with stages
in 9 minutes and 49 seconds
......@@ -287,8 +287,14 @@ pub fn init<I>(args: I, recv_callback: RecvCallback) -> Result<Arc<Context>>
I::Item: Into<std::ffi::OsString> + Clone {
use structopt::StructOpt;
#[cfg(all(feature = "use-own-logger", not(any(test, feature = "test-helpers"))))]
simple_logger::SimpleLogger::from_env().init().or_else(|e| Err(std::io::Error::new(std::io::ErrorKind::Other, e)))?;
#[cfg(all(feature = "use-own-logger", not(any(test, feature = "test-helpers"))))] {
// Allow multiple contexts to be created in a same process
static INIT: std::sync::Once = std::sync::Once::new();
let mut ret = Ok(());
INIT.call_once(|| ret = simple_logger::SimpleLogger::from_env().init().or_else(|e| Err(std::io::Error::new(std::io::ErrorKind::Other, e))));
ret
}?;
let config = Config::from_iter_safe(args).or_else(|e| Err(std::io::Error::new(std::io::ErrorKind::Other, e)))?;
debug!("{:?}", config);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment