Skip to content

Commit 1386bef

Browse files
authored
Merge pull request #3431 from tnull/2024-11-drop-logging-features
Drop log-limiting features
2 parents a92084b + f6af8e3 commit 1386bef

File tree

5 files changed

+4
-50
lines changed

5 files changed

+4
-50
lines changed

ci/ci-tests.sh

-5
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ cargo test -p lightning-custom-message --verbose --color always
106106
echo -e "\n\nTest backtrace-debug builds"
107107
cargo test -p lightning --verbose --color always --features backtrace
108108

109-
echo -e "\n\nBuilding with all Log-Limiting features"
110-
grep '^max_level_' lightning/Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
111-
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check -p lightning --verbose --color always --features "$FEATURE"
112-
done
113-
114109
echo -e "\n\nTesting no_std builds"
115110
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
116111
cargo test -p $DIR --verbose --color always --no-default-features

lightning/Cargo.toml

+1-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1818
[features]
1919
# Internal test utilities exposed to other repo crates
2020
_test_utils = ["regex", "bitcoin/bitcoinconsensus", "lightning-types/_test_utils"]
21-
# Unlog messages superior at targeted level.
22-
max_level_off = []
23-
max_level_error = []
24-
max_level_warn = []
25-
max_level_info = []
26-
max_level_debug = []
27-
max_level_trace = []
21+
2822
# Allow signing of local transactions that may have been revoked or will be revoked, for functional testing (e.g. justice tx handling).
2923
# This is unsafe to use in production because it may result in the counterparty publishing taking our funds.
3024
unsafe_revoked_tx_signing = []

lightning/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828
//!
2929
//! * `std`
3030
//! * `grind_signatures`
31-
//! * Skip logging of messages at levels below the given log level:
32-
//! * `max_level_off`
33-
//! * `max_level_error`
34-
//! * `max_level_warn`
35-
//! * `max_level_info`
36-
//! * `max_level_debug`
37-
//! * `max_level_trace`
3831
3932
#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), deny(missing_docs))]
4033
#![cfg_attr(not(any(test, feature = "_test_utils")), forbid(unsafe_code))]

lightning/src/util/logger.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
//! Log traits live here, which are called throughout the library to provide useful information for
1111
//! debugging purposes.
1212
//!
13-
//! There is currently 2 ways to filter log messages. First one, by using compilation features, e.g "max_level_off".
14-
//! The second one, client-side by implementing check against Record Level field.
15-
//! Each module may have its own Logger or share one.
13+
//! Log messages should be filtered client-side by implementing check against a given [`Record`]'s
14+
//! [`Level`] field. Each module may have its own Logger or share one.
1615
1716
use bitcoin::secp256k1::PublicKey;
1817

lightning/src/util/macro_logger.rs

+1-28
Original file line numberDiff line numberDiff line change
@@ -173,36 +173,9 @@ macro_rules! log_spendable {
173173
/// but it needs to be exported so `log_trace` etc can use it in external crates.
174174
#[doc(hidden)]
175175
#[macro_export]
176-
macro_rules! log_internal {
177-
($logger: expr, $lvl:expr, $($arg:tt)+) => (
178-
$logger.log($crate::util::logger::Record::new($lvl, None, None, format_args!($($arg)+), module_path!(), file!(), line!(), None))
179-
);
180-
}
181-
182-
/// Logs an entry at the given level.
183-
#[doc(hidden)]
184-
#[macro_export]
185176
macro_rules! log_given_level {
186177
($logger: expr, $lvl:expr, $($arg:tt)+) => (
187-
match $lvl {
188-
#[cfg(not(any(feature = "max_level_off")))]
189-
$crate::util::logger::Level::Error => $crate::log_internal!($logger, $lvl, $($arg)*),
190-
#[cfg(not(any(feature = "max_level_off", feature = "max_level_error")))]
191-
$crate::util::logger::Level::Warn => $crate::log_internal!($logger, $lvl, $($arg)*),
192-
#[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn")))]
193-
$crate::util::logger::Level::Info => $crate::log_internal!($logger, $lvl, $($arg)*),
194-
#[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info")))]
195-
$crate::util::logger::Level::Debug => $crate::log_internal!($logger, $lvl, $($arg)*),
196-
#[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info", feature = "max_level_debug")))]
197-
$crate::util::logger::Level::Trace => $crate::log_internal!($logger, $lvl, $($arg)*),
198-
#[cfg(not(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info", feature = "max_level_debug", feature = "max_level_trace")))]
199-
$crate::util::logger::Level::Gossip => $crate::log_internal!($logger, $lvl, $($arg)*),
200-
201-
#[cfg(any(feature = "max_level_off", feature = "max_level_error", feature = "max_level_warn", feature = "max_level_info", feature = "max_level_debug", feature = "max_level_trace"))]
202-
_ => {
203-
// The level is disabled at compile-time
204-
},
205-
}
178+
$logger.log($crate::util::logger::Record::new($lvl, None, None, format_args!($($arg)+), module_path!(), file!(), line!(), None))
206179
);
207180
}
208181

0 commit comments

Comments
 (0)