Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make logging with log a default feature #62

Merged
merged 2 commits into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions serial_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ parking_lot = "^0.12"
serial_test_derive = { version = "~0.7.0", path = "../serial_test_derive" }
fslock = {version = "0.2", optional = true}
document-features = {version = "0.2", optional=true}
log = "0.4"
log = {version = "0.4", optional = true}
futures = {version = "^0.3", default_features = false, features = ["executor"] }

[dev-dependencies]
itertools = "0.10"
tokio = { version = "^1.17", features = ["macros", "rt"] }

[features]
default = []
default = ["logging"]

logging = ["log"]

## The file_locks feature unlocks the `file_serial` macro
file_locks = ["fslock"]
Expand Down
2 changes: 2 additions & 0 deletions serial_test/src/code_lock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::rwlock::{Locks, MutexGuardWrapper};
use lazy_static::lazy_static;
#[cfg(feature = "logging")]
use log::debug;
use parking_lot::{Mutex, RwLock};
use std::{
Expand Down Expand Up @@ -78,6 +79,7 @@ pub(crate) fn check_new_key(name: &str) {
let start = Instant::now();
loop {
let duration = Instant::now() - start;
#[cfg(feature = "logging")]
debug!("Waiting for '{}' {:?}", name, duration);
// Check if a new key is needed. Just need a read lock, which can be done in sync with everyone else
let try_unlock = LOCKS.try_read_recursive_for(Duration::from_secs(1));
Expand Down