Skip to content

Commit

Permalink
remove logging feature
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Sep 16, 2020
1 parent 9e6bf5c commit 3a59b92
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 68 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Expand Up @@ -17,12 +17,8 @@ env:
matrix:
- JOB=test CARGO_DEFAULT_FEATURES="" CARGO_FEATURES=""
- JOB=test CARGO_DEFAULT_FEATURES="" CARGO_FEATURES="skeptic_tests"
- JOB=test CARGO_DEFAULT_FEATURES="" CARGO_FEATURES="logging"
- JOB=test CARGO_DEFAULT_FEATURES="" CARGO_FEATURES="skeptic_tests logging"
- JOB=test CARGO_DEFAULT_FEATURES="--no-default-features" CARGO_FEATURES=""
- JOB=test CARGO_DEFAULT_FEATURES="--no-default-features" CARGO_FEATURES="skeptic_tests"
- JOB=test CARGO_DEFAULT_FEATURES="--no-default-features" CARGO_FEATURES="logging"
- JOB=test CARGO_DEFAULT_FEATURES="--no-default-features" CARGO_FEATURES="skeptic_tests logging"
- JOB=test CARGO_DEFAULT_FEATURES="" CARGO_FEATURES="clippy"
global:
- RUST_BACKTRACE=1
Expand Down
1 change: 1 addition & 0 deletions derive_builder/CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
- Requires Rust 1.40.0 or newer (was 1.37.0) #169
- Logging feature is removed.

## [0.9.0] - 2019-11-07
- Add `setter(custom)` to allow implementing a custom setter #154
Expand Down
1 change: 0 additions & 1 deletion derive_builder/Cargo.toml
Expand Up @@ -22,7 +22,6 @@ travis-ci = { repository = "colin-kiegel/rust-derive-builder" }
[features]
default = ["std"]
std = []
logging = ["derive_builder_macro/logging", "derive_builder_core/logging"]
skeptic_tests = ["skeptic", "derive_builder_macro/skeptic_tests", "derive_builder_core/skeptic_tests"]
clippy = ["derive_builder_macro/clippy", "derive_builder_core/clippy"]

Expand Down
1 change: 0 additions & 1 deletion derive_builder/README.md
Expand Up @@ -98,7 +98,6 @@ with [cargo-edit](https://github.com/killercup/cargo-edit):
* **Build method suppression**: You can use `#[builder(build_fn(skip))]` to disable auto-implementation of the build method and provide your own.
* **Builder derivations**: You can use `#[builder(derive(Trait1, Trait2, ...))]` to have the builder derive additonal traits. All builders derive `Default` and `Clone`, so you should not declare those in this attribute.
* **no_std support**: Just add `#[builder(no_std)]` to your struct and add `#![feature(alloc)] extern crate alloc` to your crate. The latter requires the _nightly_ toolchain.
* **Logging**: If anything works unexpectedly you can enable detailed logs in two steps. First, add `features = ["logging"]` to the `derive_builder` dependency in `Cargo.toml`. Second, set this environment variable before calling cargo `RUST_LOG=derive_builder=trace`.

For more information and examples please take a look at our [documentation][doc].

Expand Down
10 changes: 0 additions & 10 deletions derive_builder/src/lib.rs
Expand Up @@ -525,16 +525,6 @@
//! dependency would occur. To break it you could try to depend on the
//! [`derive_builder_core`] crate instead.
//!
//! ## Debugging Info
//!
//! If you experience any problems during compilation, you can enable additional debug output in
//! two steps:
//!
//! 1. Add `features = ["logging"]` to the `derive_builder` dependency in `Cargo.toml`.
//! 2. Set this environment variable before calling cargo or rustc `RUST_LOG=derive_builder=trace`.
//!
//! Example: `env RUST_LOG=derive_builder=trace cargo test`.
//!
//! ## Report Issues and Ideas
//!
//! [Open an issue on GitHub](https://github.com/colin-kiegel/rust-derive-builder/issues)
Expand Down
4 changes: 0 additions & 4 deletions derive_builder_core/Cargo.toml
Expand Up @@ -16,7 +16,6 @@ readme = "README.md"
build = "build/mod.rs"

[features]
logging = ["env_logger"]
clippy = []
skeptic_tests = ["skeptic"]

Expand All @@ -28,12 +27,9 @@ darling = "0.10.2"
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["full", "extra-traits"] }
log = "0.4"

[dev-dependencies]
pretty_assertions = "0.6"

[build-dependencies]
skeptic = { version = "0.13", optional = true }
env_logger = { version = "0.5", optional = true }
log = "0.4"
6 changes: 0 additions & 6 deletions derive_builder_core/build/skeptic.rs
@@ -1,13 +1,7 @@
#[macro_use]
extern crate log;
#[cfg(feature = "logging")]
extern crate env_logger;
extern crate skeptic;

fn main() {
println!("INFO: Run with `RUST_LOG=build_script_build=trace` for debug information.");
#[cfg(feature = "logging")]
env_logger::init();

let mut files = generate_doc_tpl_tests().unwrap();
files.push("README.md".to_string());
Expand Down
3 changes: 0 additions & 3 deletions derive_builder_core/src/build_method.rs
Expand Up @@ -85,7 +85,6 @@ impl<'a> ToTokens for BuildMethod<'a> {
let error_ty = &self.error_ty;

if self.enabled {
trace!("Deriving build method `{}`.", self.ident);
tokens.append_all(quote!(
#doc_comment
#vis fn #ident(#self_param)
Expand All @@ -98,8 +97,6 @@ impl<'a> ToTokens for BuildMethod<'a> {
})
}
))
} else {
trace!("Skipping build method.");
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions derive_builder_core/src/builder.rs
Expand Up @@ -127,7 +127,6 @@ pub struct Builder<'a> {
impl<'a> ToTokens for Builder<'a> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if self.enabled {
trace!("Deriving builder `{}`.", self.ident);
let builder_vis = &self.visibility;
let builder_ident = &self.ident;
let bounded_generics = self.compute_impl_bounds();
Expand Down Expand Up @@ -159,11 +158,6 @@ impl<'a> ToTokens for Builder<'a> {
let builder_doc_comment = &self.doc_comment;
let deprecation_notes = &self.deprecation_notes.as_item();

debug!(
"ty_generics={:?}, where_clause={:?}, struct_generics={:?}",
ty_generics, where_clause, struct_generics
);

#[cfg(not(feature = "clippy"))]
tokens.append_all(quote!(#[allow(clippy::all)]));

Expand Down Expand Up @@ -222,8 +216,6 @@ impl<'a> ToTokens for Builder<'a> {
#deprecation_notes
}
));
} else {
trace!("Skipping builder `{}`.", self.ident);
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions derive_builder_core/src/builder_field.rs
Expand Up @@ -50,7 +50,6 @@ pub struct BuilderField<'a> {
impl<'a> ToTokens for BuilderField<'a> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if self.field_enabled {
trace!("Deriving builder field for `{}`.", self.field_ident);
let vis = &self.field_visibility;
let ident = self.field_ident;
let ty = self.field_type;
Expand All @@ -60,10 +59,6 @@ impl<'a> ToTokens for BuilderField<'a> {
#(#attrs)* #vis #ident: ::derive_builder::export::core::option::Option<#ty>,
));
} else {
trace!(
"Skipping builder field for `{}`, fallback to PhantomData.",
self.field_ident
);
let ident = self.field_ident;
let ty = self.field_type;
let attrs = self.attrs;
Expand Down
2 changes: 0 additions & 2 deletions derive_builder_core/src/initializer.rs
Expand Up @@ -52,8 +52,6 @@ pub struct Initializer<'a> {

impl<'a> ToTokens for Initializer<'a> {
fn to_tokens(&self, tokens: &mut TokenStream) {
trace!("Deriving initializer for `{}`.", self.field_ident);

let struct_field = &self.field_ident;

if self.field_enabled {
Expand Down
4 changes: 0 additions & 4 deletions derive_builder_core/src/lib.rs
Expand Up @@ -34,8 +34,6 @@ extern crate proc_macro2;
extern crate syn;
#[macro_use]
extern crate quote;
#[macro_use]
extern crate log;
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;
Expand Down Expand Up @@ -66,8 +64,6 @@ const DEFAULT_STRUCT_NAME: &str = "__default";

/// Derive a builder for a struct
pub fn builder_for_struct(ast: syn::DeriveInput) -> proc_macro2::TokenStream {
debug!("Deriving Builder for `{}`.", ast.ident);

let opts = match macro_options::Options::from_derive_input(&ast) {
Ok(val) => val,
Err(err) => {
Expand Down
5 changes: 0 additions & 5 deletions derive_builder_core/src/setter.rs
Expand Up @@ -67,7 +67,6 @@ pub struct Setter<'a> {
impl<'a> ToTokens for Setter<'a> {
fn to_tokens(&self, tokens: &mut TokenStream) {
if self.setter_enabled {
trace!("Deriving setter for `{}`.", self.field_ident);
let field_type = self.field_type;
let pattern = self.pattern;
let vis = &self.visibility;
Expand Down Expand Up @@ -153,11 +152,7 @@ impl<'a> ToTokens for Setter<'a> {
new.#field_ident = ::derive_builder::export::core::option::Option::Some(converted);
Ok(new)
}));
} else {
trace!("Skipping try_setter for `{}`.", self.field_ident);
}
} else {
trace!("Skipping setter for `{}`.", self.field_ident);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions derive_builder_macro/Cargo.toml
Expand Up @@ -22,11 +22,9 @@ travis-ci = { repository = "colin-kiegel/rust-derive-builder" }
proc-macro = true

[features]
logging = ["env_logger"]
clippy = ["derive_builder_core/clippy"]
skeptic_tests = ["derive_builder_core/skeptic_tests"]

[dependencies]
syn = { version = "1", features = ["full", "extra-traits"] }
env_logger = { version = "0.5", optional = true }
derive_builder_core = { version = "=0.10.0-alpha", path = "../derive_builder_core" }
13 changes: 0 additions & 13 deletions derive_builder_macro/src/lib.rs
Expand Up @@ -7,25 +7,12 @@ extern crate proc_macro;
#[macro_use]
extern crate syn;
extern crate derive_builder_core;
#[cfg(feature = "logging")]
extern crate env_logger;

use proc_macro::TokenStream;
#[cfg(feature = "logging")]
use std::sync::Once;

#[cfg(feature = "logging")]
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();
});

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

derive_builder_core::builder_for_struct(ast).into()
}

0 comments on commit 3a59b92

Please sign in to comment.