common: don't send trace messages by default, don't ratelimit at all.

We ratelimited DEBUG messages, but that can be annoying and cause us to miss things.
We demoted the worst offenders in the last release, to TRACE level.

Now, only log trace if it's wanted, and never suppress DEBUG.

Changelog-Changed: Logging: we no longer suppress DEBUG messages from subdaemons.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fixes: https://github.com/ElementsProject/lightning/issues/7917
This commit is contained in:
Rusty Russell
2024-12-13 15:07:51 +10:30
parent 7703cf7fec
commit 73415d35c9
9 changed files with 27 additions and 24 deletions

View File

@@ -15,12 +15,9 @@
static int status_fd = -1;
static struct daemon_conn *status_conn;
volatile bool logging_io = false;
bool logging_trace = false;
static bool was_logging_io;
/* If we're more than this many msgs deep, don't add debug messages. */
#define TRACE_QUEUE_LIMIT 20
static size_t traces_suppressed;
static void got_sigusr1(int signal UNUSED)
{
logging_io = !logging_io;
@@ -149,22 +146,10 @@ void status_vfmt(enum log_level level,
{
char *str;
/* We only suppress async debug msgs. IO messages are even spammier
* but they only occur when explicitly asked for */
if ((level == LOG_DBG || level == LOG_TRACE) && status_conn) {
size_t qlen = daemon_conn_queue_length(status_conn);
/* These are spammy, so only log if requested (or IO logging)*/
if (level == LOG_TRACE && (!logging_trace && !logging_io))
return;
/* Once suppressing, we keep suppressing until we're empty */
if (traces_suppressed && qlen == 0) {
size_t n = traces_suppressed;
traces_suppressed = 0;
/* Careful: recursion! */
status_trace("...[%zu debug/trace messages suppressed]...", n);
} else if (traces_suppressed || qlen > TRACE_QUEUE_LIMIT) {
traces_suppressed++;
return;
}
}
str = tal_vfmt(NULL, fmt, ap);
status_send(take(towire_status_log(NULL, level, peer, str)));
tal_free(str);

View File

@@ -26,6 +26,8 @@ void status_vfmt(enum log_level level,
/* Usually we only log the packet names, not contents. */
extern volatile bool logging_io;
/* Usually we don't bother with TRACE spam */
extern bool logging_trace;
/* This logs a debug summary if IO logging not enabled. */
void status_peer_io(enum log_level iodir,

View File

@@ -30,6 +30,8 @@ bool subdaemon_setup(int argc, char *argv[])
for (int i = 1; i < argc; i++) {
if (streq(argv[i], "--log-io"))
logging_io = true;
if (streq(argv[i], "--log-trace"))
logging_trace = true;
}
developer = daemon_developer_mode(argv);