From 39415d3df35ee96775213b5915cc784f24224f75 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 17 Jul 2023 17:06:07 +0930 Subject: [PATCH] lightningd: have opt_log_level take the log_book. This is where it's set, not some random logger. Signed-off-by: Rusty Russell --- lightningd/log.c | 26 +++++++++++++------------- lightningd/log.h | 4 ++-- lightningd/options.c | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lightningd/log.c b/lightningd/log.c index 36507d056..a7567f465 100644 --- a/lightningd/log.c +++ b/lightningd/log.c @@ -578,7 +578,7 @@ static void log_one_line(unsigned int skipped, data->prefix = "\n"; } -char *opt_log_level(const char *arg, struct logger *log) +char *opt_log_level(const char *arg, struct log_book *log_book) { enum log_level level; int len; @@ -588,34 +588,34 @@ char *opt_log_level(const char *arg, struct logger *log) return tal_fmt(tmpctx, "unknown log level %.*s", len, arg); if (arg[len]) { - struct print_filter *f = tal(log->log_book, struct print_filter); + struct print_filter *f = tal(log_book, struct print_filter); f->prefix = arg + len + 1; f->level = level; - list_add_tail(&log->log_book->print_filters, &f->list); + list_add_tail(&log_book->print_filters, &f->list); } else { - tal_free(log->log_book->default_print_level); - log->log_book->default_print_level = tal(log->log_book, enum log_level); - *log->log_book->default_print_level = level; + tal_free(log_book->default_print_level); + log_book->default_print_level = tal(log_book, enum log_level); + *log_book->default_print_level = level; } return NULL; } -void json_add_opt_log_levels(struct json_stream *response, struct logger *log) +void json_add_opt_log_levels(struct json_stream *response, struct log_book *log_book) { struct print_filter *i; - list_for_each(&log->log_book->print_filters, i, list) { + list_for_each(&log_book->print_filters, i, list) { json_add_str_fmt(response, "log-level", "%s:%s", log_level_name(i->level), i->prefix); } } -static bool show_log_level(char *buf, size_t len, const struct logger *log) +static bool show_log_level(char *buf, size_t len, const struct log_book *log_book) { enum log_level l; - if (log->log_book->default_print_level) - l = *log->log_book->default_print_level; + if (log_book->default_print_level) + l = *log_book->default_print_level; else l = DEFAULT_LOGLEVEL; strncpy(buf, log_level_name(l), len); @@ -739,11 +739,11 @@ char *arg_log_to_file(const char *arg, struct lightningd *ld) void opt_register_logging(struct lightningd *ld) { opt_register_early_arg("--log-level", - opt_log_level, show_log_level, ld->log, + opt_log_level, show_log_level, ld->log_book, "log level (io, debug, info, unusual, broken) [:prefix]"); clnopt_witharg("--log-timestamps", OPT_EARLY|OPT_SHOWBOOL, opt_set_bool_arg, opt_show_bool, - &ld->log->log_book->print_timestamps, + &ld->log_book->print_timestamps, "prefix log messages with timestamp"); opt_register_early_arg("--log-prefix", arg_log_prefix, show_log_prefix, ld->log_book, diff --git a/lightningd/log.h b/lightningd/log.h index 567563f50..3812788bc 100644 --- a/lightningd/log.h +++ b/lightningd/log.h @@ -90,7 +90,7 @@ struct log_entry { }; /* For options.c's listconfig */ -char *opt_log_level(const char *arg, struct logger *logger); -void json_add_opt_log_levels(struct json_stream *response, struct logger *logger); +char *opt_log_level(const char *arg, struct log_book *log_book); +void json_add_opt_log_levels(struct json_stream *response, struct log_book *log_book); void logging_options_parsed(struct log_book *log_book); #endif /* LIGHTNING_LIGHTNINGD_LOG_H */ diff --git a/lightningd/options.c b/lightningd/options.c index 9ae656bbb..004ec5411 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1895,7 +1895,7 @@ void add_config_deprecated(struct lightningd *ld, } else if (opt->cb_arg == (void *)opt_add_plugin) { json_add_opt_plugins(response, ld->plugins); } else if (opt->cb_arg == (void *)opt_log_level) { - json_add_opt_log_levels(response, ld->log); + json_add_opt_log_levels(response, ld->log_book); } else if (opt->cb_arg == (void *)opt_disable_plugin) { json_add_opt_disable_plugins(response, ld->plugins); } else if (opt->cb_arg == (void *)opt_force_feerates) {