Skip to content

Commit

Permalink
fix logging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Jul 29, 2020
1 parent 01abba2 commit e29f1cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions derive_builder/build/skeptic.rs
Expand Up @@ -14,7 +14,7 @@ mod log_disabled {
fn main() {
println!("INFO: Run with `RUST_LOG=build_script_build=trace` for debug information.");
#[cfg(feature = "logging")]
env_logger::init().unwrap();
env_logger::init();

let mut files = generate_doc_tpl_tests().unwrap();
files.push("README.md".to_string());
Expand Down Expand Up @@ -62,7 +62,7 @@ use std::io::{Write, Read};
const DOC_TPL_DIR: &'static str = "src/doc_tpl/";
const DOC_TPL_OUT_DIR: &'static str = "doc_tpl/";

fn generate_doc_tpl_tests() -> Result<Vec<String>, Box<Error>> {
fn generate_doc_tpl_tests() -> Result<Vec<String>, Box<dyn Error>> {
trace!("Generating doc template tests");
let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
let mut tpl_dir = root_dir;
Expand Down
6 changes: 3 additions & 3 deletions derive_builder/src/lib.rs
Expand Up @@ -581,17 +581,17 @@ use darling::FromDeriveInput;
use options::Options;
use proc_macro::TokenStream;
#[cfg(feature = "logging")]
use std::sync::{Once, ONCE_INIT};
use std::sync::Once;

#[cfg(feature = "logging")]
static INIT_LOGGER: Once = ONCE_INIT;
static INIT_LOGGER: Once = Once::new();

#[doc(hidden)]
#[proc_macro_derive(Builder, attributes(builder))]
pub fn derive(input: TokenStream) -> TokenStream {
#[cfg(feature = "logging")]
INIT_LOGGER.call_once(|| {
env_logger::init().unwrap();
env_logger::init();
});

let ast = parse_macro_input!(input as syn::DeriveInput);
Expand Down

0 comments on commit e29f1cc

Please sign in to comment.