Skip to content

Commit 73415d3

Browse files
committed
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 <[email protected]> Fixes: #7917
1 parent 7703cf7 commit 73415d3

File tree

9 files changed

+28
-25
lines changed

9 files changed

+28
-25
lines changed

common/status.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
static int status_fd = -1;
1616
static struct daemon_conn *status_conn;
1717
volatile bool logging_io = false;
18+
bool logging_trace = false;
1819
static bool was_logging_io;
1920

20-
/* If we're more than this many msgs deep, don't add debug messages. */
21-
#define TRACE_QUEUE_LIMIT 20
22-
static size_t traces_suppressed;
23-
2421
static void got_sigusr1(int signal UNUSED)
2522
{
2623
logging_io = !logging_io;
@@ -149,22 +146,10 @@ void status_vfmt(enum log_level level,
149146
{
150147
char *str;
151148

152-
/* We only suppress async debug msgs. IO messages are even spammier
153-
* but they only occur when explicitly asked for */
154-
if ((level == LOG_DBG || level == LOG_TRACE) && status_conn) {
155-
size_t qlen = daemon_conn_queue_length(status_conn);
156-
157-
/* Once suppressing, we keep suppressing until we're empty */
158-
if (traces_suppressed && qlen == 0) {
159-
size_t n = traces_suppressed;
160-
traces_suppressed = 0;
161-
/* Careful: recursion! */
162-
status_trace("...[%zu debug/trace messages suppressed]...", n);
163-
} else if (traces_suppressed || qlen > TRACE_QUEUE_LIMIT) {
164-
traces_suppressed++;
165-
return;
166-
}
167-
}
149+
/* These are spammy, so only log if requested (or IO logging)*/
150+
if (level == LOG_TRACE && (!logging_trace && !logging_io))
151+
return;
152+
168153
str = tal_vfmt(NULL, fmt, ap);
169154
status_send(take(towire_status_log(NULL, level, peer, str)));
170155
tal_free(str);

common/status.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ void status_vfmt(enum log_level level,
2626

2727
/* Usually we only log the packet names, not contents. */
2828
extern volatile bool logging_io;
29+
/* Usually we don't bother with TRACE spam */
30+
extern bool logging_trace;
2931

3032
/* This logs a debug summary if IO logging not enabled. */
3133
void status_peer_io(enum log_level iodir,

common/subdaemon.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ bool subdaemon_setup(int argc, char *argv[])
3030
for (int i = 1; i < argc; i++) {
3131
if (streq(argv[i], "--log-io"))
3232
logging_io = true;
33+
if (streq(argv[i], "--log-trace"))
34+
logging_trace = true;
3335
}
3436

3537
developer = daemon_developer_mode(argv);

connectd/test/run-netaddress.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ u8 *b32_decode(const tal_t *ctx UNNEEDED, const char *str UNNEEDED, size_t len U
5353
/* Generated stub for b32_encode */
5454
char *b32_encode(const tal_t *ctx UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
5555
{ fprintf(stderr, "b32_encode called!\n"); abort(); }
56-
/* Generated stub for daemon_conn_queue_length */
57-
size_t daemon_conn_queue_length(const struct daemon_conn *dc UNNEEDED)
58-
{ fprintf(stderr, "daemon_conn_queue_length called!\n"); abort(); }
5956
/* Generated stub for daemon_conn_send */
6057
void daemon_conn_send(struct daemon_conn *dc UNNEEDED, const u8 *msg UNNEEDED)
6158
{ fprintf(stderr, "daemon_conn_send called!\n"); abort(); }

lightningd/log.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ bool log_has_io_logging(const struct logger *log)
478478
return print_level(log->log_book, log->prefix, log->default_node_id, NULL) < LOG_TRACE;
479479
}
480480

481+
bool log_has_trace_logging(const struct logger *log)
482+
{
483+
return print_level(log->log_book, log->prefix, log->default_node_id, NULL) < LOG_DBG;
484+
}
485+
481486
/* This may move entry! */
482487
static void add_entry(struct logger *log, struct log_entry **l)
483488
{

lightningd/log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ void logv(struct logger *logger, enum log_level level, const struct node_id *nod
4848
const char *log_prefix(const struct logger *logger);
4949
/* Is there any chance we do io-level logging for this node_id in log? */
5050
bool log_has_io_logging(const struct logger *log);
51+
/* How about trace logging? */
52+
bool log_has_trace_logging(const struct logger *log);
5153

5254
void opt_register_logging(struct lightningd *ld);
5355

lightningd/subd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static int subd(const char *path, const char *name,
205205
bool debugging,
206206
int *msgfd,
207207
bool io_logging,
208+
bool trace_logging,
208209
bool developer,
209210
va_list *ap)
210211
{
@@ -228,7 +229,7 @@ static int subd(const char *path, const char *name,
228229

229230
if (childpid == 0) {
230231
size_t num_args;
231-
char *args[] = { NULL, NULL, NULL, NULL, NULL };
232+
char *args[] = { NULL, NULL, NULL, NULL, NULL, NULL };
232233
int **fds = tal_arr(tmpctx, int *, 3);
233234
int stdoutfd = STDOUT_FILENO, stderrfd = STDERR_FILENO;
234235

@@ -259,6 +260,8 @@ static int subd(const char *path, const char *name,
259260
args[num_args++] = tal_strdup(NULL, path);
260261
if (io_logging)
261262
args[num_args++] = "--log-io";
263+
if (trace_logging)
264+
args[num_args++] = "--log-trace";
262265
if (debugging)
263266
args[num_args++] = "--dev-debug-self";
264267
if (developer)
@@ -742,9 +745,10 @@ static struct subd *new_subd(const tal_t *ctx,
742745

743746
sd->pid = subd(path, name, debugging(ld, name),
744747
&msg_fd,
745-
/* We only turn on subdaemon io logging if we're going
748+
/* We only turn on subdaemon io/trace logging if we're going
746749
* to print it: too stressful otherwise! */
747750
log_has_io_logging(sd->log),
751+
log_has_trace_logging(sd->log),
748752
ld->developer,
749753
ap);
750754
if (sd->pid == (pid_t)-1) {

lightningd/test/run-find_my_abspath.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ void log_backtrace_print(const char *fmt UNNEEDED, ...)
173173
/* Generated stub for log_has_io_logging */
174174
bool log_has_io_logging(const struct logger *log UNNEEDED)
175175
{ fprintf(stderr, "log_has_io_logging called!\n"); abort(); }
176+
/* Generated stub for log_has_trace_logging */
177+
bool log_has_trace_logging(const struct logger *log UNNEEDED)
178+
{ fprintf(stderr, "log_has_trace_logging called!\n"); abort(); }
176179
/* Generated stub for log_prefix */
177180
const char *log_prefix(const struct logger *logger UNNEEDED)
178181
{ fprintf(stderr, "log_prefix called!\n"); abort(); }

lightningd/test/run-shuffle_fds.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ void log_(struct logger *logger UNNEEDED, enum log_level level UNNEEDED,
8686
/* Generated stub for log_has_io_logging */
8787
bool log_has_io_logging(const struct logger *log UNNEEDED)
8888
{ fprintf(stderr, "log_has_io_logging called!\n"); abort(); }
89+
/* Generated stub for log_has_trace_logging */
90+
bool log_has_trace_logging(const struct logger *log UNNEEDED)
91+
{ fprintf(stderr, "log_has_trace_logging called!\n"); abort(); }
8992
/* Generated stub for log_prefix */
9093
const char *log_prefix(const struct logger *logger UNNEEDED)
9194
{ fprintf(stderr, "log_prefix called!\n"); abort(); }

0 commit comments

Comments
 (0)