mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 08:04:26 +01:00
lightningd: don't return to a default filter level if there are no per-file filters.
In this case, the user's default was info, but they specifically asked for debug from one plugin. Since there were no per-file filters, it set filtering to the default level, info, and rejected it. Since it's been explicitly filtered in, we need to pass it at this point. Reported-by: @wtogami Fixes: #6503 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -206,6 +206,7 @@ static void log_to_files(const char *log_prefix,
|
|||||||
{
|
{
|
||||||
char tstamp[sizeof("YYYY-mm-ddTHH:MM:SS.nnnZ ")];
|
char tstamp[sizeof("YYYY-mm-ddTHH:MM:SS.nnnZ ")];
|
||||||
char *entry, *nodestr;
|
char *entry, *nodestr;
|
||||||
|
bool filtered;
|
||||||
|
|
||||||
if (print_timestamps) {
|
if (print_timestamps) {
|
||||||
char iso8601_msec_fmt[sizeof("YYYY-mm-ddTHH:MM:SS.%03dZ ")];
|
char iso8601_msec_fmt[sizeof("YYYY-mm-ddTHH:MM:SS.%03dZ ")];
|
||||||
@@ -243,12 +244,15 @@ static void log_to_files(const char *log_prefix,
|
|||||||
|
|
||||||
/* In complex configurations, we tell loggers to overshare: then we
|
/* In complex configurations, we tell loggers to overshare: then we
|
||||||
* need to filter here to see if we really want it. */
|
* need to filter here to see if we really want it. */
|
||||||
|
filtered = false;
|
||||||
if (print_filters) {
|
if (print_filters) {
|
||||||
enum log_level filter;
|
enum log_level filter;
|
||||||
if (filter_level(print_filters,
|
if (filter_level(print_filters,
|
||||||
entry_prefix, nodestr, &filter)) {
|
entry_prefix, nodestr, &filter)) {
|
||||||
if (level < filter)
|
if (level < filter)
|
||||||
return;
|
return;
|
||||||
|
/* Even if they specify a default filter level of 'INFO', this overrides */
|
||||||
|
filtered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,10 +268,15 @@ static void log_to_files(const char *log_prefix,
|
|||||||
if (!filter_level(&log_files[i]->print_filters,
|
if (!filter_level(&log_files[i]->print_filters,
|
||||||
entry_prefix, nodestr, &filter)) {
|
entry_prefix, nodestr, &filter)) {
|
||||||
/* If we haven't set default yet, only log UNUSUAL */
|
/* If we haven't set default yet, only log UNUSUAL */
|
||||||
if (default_print_level)
|
if (!default_print_level)
|
||||||
filter = *default_print_level;
|
|
||||||
else
|
|
||||||
filter = LOG_UNUSUAL;
|
filter = LOG_UNUSUAL;
|
||||||
|
else {
|
||||||
|
/* If we've filtered it already, it passes */
|
||||||
|
if (filtered)
|
||||||
|
filter = level;
|
||||||
|
else
|
||||||
|
filter = *default_print_level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (level < filter)
|
if (level < filter)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -3076,7 +3076,6 @@ def test_log_filter(node_factory):
|
|||||||
assert all([' {}-'.format(l1.info['id']) in l for l in lines])
|
assert all([' {}-'.format(l1.info['id']) in l for l in lines])
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(strict=True)
|
|
||||||
def test_log_filter_bug(node_factory):
|
def test_log_filter_bug(node_factory):
|
||||||
"""Test the log-level option with overriding to a more verbose setting"""
|
"""Test the log-level option with overriding to a more verbose setting"""
|
||||||
log_plugin = os.path.join(os.getcwd(), 'tests/plugins/log.py')
|
log_plugin = os.path.join(os.getcwd(), 'tests/plugins/log.py')
|
||||||
|
|||||||
Reference in New Issue
Block a user