Skip to content

Commit dc282ff

Browse files
committed
Merge bitcoin/bitcoin#35597: logging: More fully remove libevent log category
3765b42 logging: More fully remove libevent log category (Ryan Ofsky) Pull request description: Libevent log category was partially removed in 39e9099, and this commit extends that with the following changes: - Stops showing libevent in the list of supported log categories in `bitcoind -help` and `bitcoin-cli help logging` output. - Stops returning `"libevent": false` in `logging` RPC output. It's not good to treat libevent as a supported log category when it can't be enabled and trying to enable it results in warnings. There's also no need to define an unused LIBEVENT constant value and keep more complicated logic for dealing with deprecated log categories, so this change also simplifies code internally. ACKs for top commit: l0rinc: code review ACK 3765b42 pinheadmz: ACK 3765b42 sedited: ACK 3765b42 Tree-SHA512: 09e9514f905bb0a79d870689af491886baaa31fa19f2ad6aef4283fa20c2fa6ce8d384178139227aeeabffabff6e83d254114daaeefbbfe2c6172b9da8871298
2 parents ec98037 + 3765b42 commit dc282ff

5 files changed

Lines changed: 42 additions & 46 deletions

File tree

doc/release-notes-35182.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ HTTP: RPC / REST
33

44
The HTTP server has been rewritten from scratch to replace libevent. (#35182)
55

6-
`libevent` has been deprecated as a logging category and will be removed in
7-
a future release. At that time configurations like `debugexclude=libevent` will
8-
be invalid.
6+
The `libevent` logging category has been removed. Configurations like
7+
`-debug=libevent` or `-debugexclude=libevent` will log a deprecation warning
8+
and be ignored. These configurations will result in an error in a future release.
99

1010
Certain HTTP edge cases will observe different behavior to be more RFC-compliant:
1111

src/logging.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
133133
bool BCLog::Logger::EnableCategory(std::string_view str)
134134
{
135135
if (const auto flag{GetLogCategory(str)}) {
136-
if (*flag & DEPRECATED){
137-
LogWarning("The logging category `%s` is deprecated, can not be enabled, and will be removed in a future version", str);
138-
// Deprecated does not mean unsupported, which may prevent startup
139-
return true;
140-
}
141136
EnableCategory(*flag);
142137
return true;
143138
}
@@ -152,11 +147,6 @@ void BCLog::Logger::DisableCategory(BCLog::LogFlags flag)
152147
bool BCLog::Logger::DisableCategory(std::string_view str)
153148
{
154149
if (const auto flag{GetLogCategory(str)}) {
155-
if (*flag & DEPRECATED){
156-
LogWarning("The logging category `%s` is deprecated and will be removed in a future version", str);
157-
// Deprecated does not mean unsupported, which may prevent startup
158-
return true;
159-
}
160150
DisableCategory(*flag);
161151
return true;
162152
}
@@ -204,7 +194,6 @@ static const std::map<std::string, BCLog::LogFlags, std::less<>> LOG_CATEGORIES_
204194
{"prune", BCLog::PRUNE},
205195
{"proxy", BCLog::PROXY},
206196
{"mempoolrej", BCLog::MEMPOOLREJ},
207-
{"libevent", BCLog::LIBEVENT},
208197
{"coindb", BCLog::COINDB},
209198
{"qt", BCLog::QT},
210199
{"leveldb", BCLog::LEVELDB},
@@ -243,6 +232,10 @@ std::optional<BCLog::LogFlags> BCLog::Logger::GetLogCategory(std::string_view st
243232
if (it != LOG_CATEGORIES_BY_STR.end()) {
244233
return it->second;
245234
}
235+
if (str == "libevent") {
236+
LogWarning("The logging category `%s` is deprecated, does nothing, and will be removed in a future version", str);
237+
return BCLog::NONE;
238+
}
246239
return std::nullopt;
247240
}
248241

@@ -616,6 +609,7 @@ bool BCLog::Logger::SetCategoryLogLevel(std::string_view category_str, std::stri
616609

617610
const auto level = GetLogLevel(level_str);
618611
if (!level.has_value() || level.value() > MAX_USER_SETABLE_SEVERITY_LEVEL) return false;
612+
if (*flag == BCLog::NONE) return true;
619613

620614
STDLOCK(m_cs);
621615
m_category_log_levels[*flag] = level.value();

src/logging/categories.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,24 @@ enum LogFlags : CategoryMask {
3030
PRUNE = (CategoryMask{1} << 14),
3131
PROXY = (CategoryMask{1} << 15),
3232
MEMPOOLREJ = (CategoryMask{1} << 16),
33-
LIBEVENT = (CategoryMask{1} << 17),
34-
COINDB = (CategoryMask{1} << 18),
35-
QT = (CategoryMask{1} << 19),
36-
LEVELDB = (CategoryMask{1} << 20),
37-
VALIDATION = (CategoryMask{1} << 21),
38-
I2P = (CategoryMask{1} << 22),
39-
IPC = (CategoryMask{1} << 23),
33+
COINDB = (CategoryMask{1} << 17),
34+
QT = (CategoryMask{1} << 18),
35+
LEVELDB = (CategoryMask{1} << 19),
36+
VALIDATION = (CategoryMask{1} << 20),
37+
I2P = (CategoryMask{1} << 21),
38+
IPC = (CategoryMask{1} << 22),
4039
#ifdef DEBUG_LOCKCONTENTION
41-
LOCK = (CategoryMask{1} << 24),
40+
LOCK = (CategoryMask{1} << 23),
4241
#endif
43-
BLOCKSTORAGE = (CategoryMask{1} << 25),
44-
TXRECONCILIATION = (CategoryMask{1} << 26),
45-
SCAN = (CategoryMask{1} << 27),
46-
TXPACKAGES = (CategoryMask{1} << 28),
47-
KERNEL = (CategoryMask{1} << 29),
48-
PRIVBROADCAST = (CategoryMask{1} << 30),
49-
DEPRECATED = LIBEVENT,
50-
// Remove deprecated categories from ALL
51-
ALL = ~DEPRECATED,
42+
BLOCKSTORAGE = (CategoryMask{1} << 24),
43+
TXRECONCILIATION = (CategoryMask{1} << 25),
44+
SCAN = (CategoryMask{1} << 26),
45+
TXPACKAGES = (CategoryMask{1} << 27),
46+
KERNEL = (CategoryMask{1} << 28),
47+
PRIVBROADCAST = (CategoryMask{1} << 29),
48+
ALL = ~NONE,
5249
};
50+
5351
} // namespace BCLog
5452

5553
#endif // BITCOIN_LOGGING_CATEGORIES_H

src/test/logging_tests.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,7 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros_CategoryName, LogSetup)
167167
for (const auto& category_name : category_names) {
168168
const auto trimmed_category_name = TrimString(category_name);
169169
const auto category{*Assert(BCLog::Logger::GetLogCategory(trimmed_category_name))};
170-
if (category & BCLog::LogFlags::ALL) {
171-
expected_category_names.emplace_back(category, trimmed_category_name);
172-
} else {
173-
BOOST_CHECK(category & BCLog::LogFlags::DEPRECATED);
174-
}
170+
expected_category_names.emplace_back(category, trimmed_category_name);
175171
}
176172

177173
std::vector<std::string> expected;
@@ -272,6 +268,13 @@ BOOST_FIXTURE_TEST_CASE(logging_Conf, LogSetup)
272268
BOOST_CHECK(http_it != category_levels.end());
273269
BOOST_CHECK_EQUAL(http_it->second, BCLog::Level::Info);
274270
}
271+
272+
// Removed categories (like "libevent") should not store a category-specific level
273+
{
274+
ResetLogger();
275+
BOOST_CHECK(LogInstance().SetCategoryLogLevel(/*category_str=*/"libevent", /*level_str=*/"trace"));
276+
BOOST_CHECK(LogInstance().CategoryLevels().empty());
277+
}
275278
}
276279

277280
struct ScopedScheduler {

test/functional/rpc_misc.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,17 @@ def run_test(self):
121121
assert_equal(node.getindexinfo("foo"), {})
122122

123123
# Test a deprecated category
124-
node.logging(include=['all'])
125-
for category, value in node.logging().items():
126-
# Everything True except one...
127-
assert_equal(value, category != "libevent")
128-
with self.nodes[0].assert_debug_log(["The logging category `libevent` is deprecated"]):
129-
node.logging(include=['libevent'])
130-
assert_equal(node.logging()['libevent'], False)
131-
with self.nodes[0].assert_debug_log(["The logging category `libevent` is deprecated"]):
132-
node.logging(exclude=['libevent'])
133-
assert_equal(node.logging()['libevent'], False)
124+
all_result = node.logging(include=['all'])
125+
assert_equal(True, all(enabled is True for category, enabled in all_result.items()))
126+
assert_equal(True, 'libevent' not in all_result)
127+
assert_equal(all_result, node.logging())
128+
libevent_warning = "The logging category `libevent` is deprecated"
129+
with self.nodes[0].assert_debug_log([libevent_warning]):
130+
assert_equal(all_result, node.logging(include=['libevent']))
131+
assert_equal(all_result, node.logging())
132+
with self.nodes[0].assert_debug_log([libevent_warning]):
133+
assert_equal(all_result, node.logging(exclude=['libevent']))
134+
assert_equal(all_result, node.logging())
134135

135136

136137
if __name__ == '__main__':

0 commit comments

Comments
 (0)