lightningd/log: clean up nomenclature.

`struct log` becomes `struct logger`, and the member which points to the
`struct log_book` becomes `->log_book` not `->lr`.

Also, we don't need to keep the log_book in struct plugin, since it has
access to ld's log_book.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-07-16 15:26:52 +09:30
parent 19d80e1f08
commit c074fe050f
37 changed files with 254 additions and 256 deletions

View File

@ -38,7 +38,7 @@ static void adjust_io_write(struct json_out *jout,
struct json_stream *new_json_stream(const tal_t *ctx, struct json_stream *new_json_stream(const tal_t *ctx,
struct command *writer, struct command *writer,
struct log *log) struct logger *log)
{ {
struct json_stream *js = tal(ctx, struct json_stream); struct json_stream *js = tal(ctx, struct json_stream);
@ -73,7 +73,7 @@ const char *json_stream_detach_filter(const tal_t *ctx, struct json_stream *js)
struct json_stream *json_stream_dup(const tal_t *ctx, struct json_stream *json_stream_dup(const tal_t *ctx,
struct json_stream *original, struct json_stream *original,
struct log *log) struct logger *log)
{ {
struct json_stream *js = tal_dup(ctx, struct json_stream, original); struct json_stream *js = tal_dup(ctx, struct json_stream, original);

View File

@ -17,7 +17,7 @@
struct command; struct command;
struct io_conn; struct io_conn;
struct log; struct logger;
struct json_escape; struct json_escape;
struct pubkey; struct pubkey;
struct bip340sig; struct bip340sig;
@ -53,7 +53,7 @@ struct json_stream {
struct json_filter *filter; struct json_filter *filter;
/* Where to log I/O */ /* Where to log I/O */
struct log *log; struct logger *log;
}; };
@ -64,7 +64,7 @@ struct json_stream {
* @log: where to log the IO * @log: where to log the IO
*/ */
struct json_stream *new_json_stream(const tal_t *ctx, struct command *writer, struct json_stream *new_json_stream(const tal_t *ctx, struct command *writer,
struct log *log); struct logger *log);
/** /**
* Duplicate an existing stream. * Duplicate an existing stream.
@ -80,7 +80,7 @@ struct json_stream *new_json_stream(const tal_t *ctx, struct command *writer,
*/ */
struct json_stream *json_stream_dup(const tal_t *ctx, struct json_stream *json_stream_dup(const tal_t *ctx,
struct json_stream *original, struct json_stream *original,
struct log *log); struct logger *log);
/* Attach a filter. Usually this works at the result level: you don't /* Attach a filter. Usually this works at the result level: you don't
* want to filter out id, etc! */ * want to filter out id, etc! */

View File

@ -127,6 +127,9 @@ int segwit_addr_decode(
const char* addr const char* addr
) )
{ fprintf(stderr, "segwit_addr_decode called!\n"); abort(); } { fprintf(stderr, "segwit_addr_decode called!\n"); abort(); }
/* Generated stub for to_canonical_invstr */
const char *to_canonical_invstr(const tal_t *ctx UNNEEDED, const char *invstring UNNEEDED)
{ fprintf(stderr, "to_canonical_invstr called!\n"); abort(); }
/* Generated stub for towire */ /* Generated stub for towire */
void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED) void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
{ fprintf(stderr, "towire called!\n"); abort(); } { fprintf(stderr, "towire called!\n"); abort(); }
@ -152,9 +155,6 @@ void towire_u8(u8 **pptr UNNEEDED, u8 v UNNEEDED)
/* Generated stub for towire_u8_array */ /* Generated stub for towire_u8_array */
void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED) void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "towire_u8_array called!\n"); abort(); } { fprintf(stderr, "towire_u8_array called!\n"); abort(); }
/* Generated stub for strip_lightning_prefix */
const char *to_canonical_invstr(const tal_t *ctx, const char *invstring UNNEEDED)
{ fprintf(stderr, "strip_lightning_prefix called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */ /* AUTOGENERATED MOCKS END */
bool deprecated_apis; bool deprecated_apis;

View File

@ -162,6 +162,9 @@ int segwit_addr_decode(
const char* addr const char* addr
) )
{ fprintf(stderr, "segwit_addr_decode called!\n"); abort(); } { fprintf(stderr, "segwit_addr_decode called!\n"); abort(); }
/* Generated stub for to_canonical_invstr */
const char *to_canonical_invstr(const tal_t *ctx UNNEEDED, const char *invstring UNNEEDED)
{ fprintf(stderr, "to_canonical_invstr called!\n"); abort(); }
/* Generated stub for towire */ /* Generated stub for towire */
void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED) void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
{ fprintf(stderr, "towire called!\n"); abort(); } { fprintf(stderr, "towire called!\n"); abort(); }
@ -187,9 +190,6 @@ void towire_u8(u8 **pptr UNNEEDED, u8 v UNNEEDED)
/* Generated stub for towire_u8_array */ /* Generated stub for towire_u8_array */
void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED) void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "towire_u8_array called!\n"); abort(); } { fprintf(stderr, "towire_u8_array called!\n"); abort(); }
/* Generated stub for strip_lightning_prefix */
const char *to_canonical_invstr(const tal_t *ctx, const char *invstring UNNEEDED)
{ fprintf(stderr, "strip_lightning_prefix called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */ /* AUTOGENERATED MOCKS END */
struct json { struct json {

View File

@ -40,15 +40,15 @@ struct command_result *command_fail(struct command *cmd,
/* Generated stub for command_filter_ptr */ /* Generated stub for command_filter_ptr */
struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED) struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_filter_ptr called!\n"); abort(); } { fprintf(stderr, "command_filter_ptr called!\n"); abort(); }
/* Generated stub for strip_lightning_prefix */
const char *to_canonical_invstr(const tal_t *ctx, const char *invstring UNNEEDED)
{ fprintf(stderr, "strip_lightning_prefix called!\n"); abort(); }
/* Generated stub for fromwire_tlv */ /* Generated stub for fromwire_tlv */
bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED, const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED,
void *record UNNEEDED, struct tlv_field **fields UNNEEDED, void *record UNNEEDED, struct tlv_field **fields UNNEEDED,
const u64 *extra_types UNNEEDED, size_t *err_off UNNEEDED, u64 *err_type UNNEEDED) const u64 *extra_types UNNEEDED, size_t *err_off UNNEEDED, u64 *err_type UNNEEDED)
{ fprintf(stderr, "fromwire_tlv called!\n"); abort(); } { fprintf(stderr, "fromwire_tlv called!\n"); abort(); }
/* Generated stub for to_canonical_invstr */
const char *to_canonical_invstr(const tal_t *ctx UNNEEDED, const char *invstring UNNEEDED)
{ fprintf(stderr, "to_canonical_invstr called!\n"); abort(); }
/* Generated stub for towire_tlv */ /* Generated stub for towire_tlv */
void towire_tlv(u8 **pptr UNNEEDED, void towire_tlv(u8 **pptr UNNEEDED,
const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED, const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED,

View File

@ -853,7 +853,7 @@ static void destroy_bitcoind(struct bitcoind *bitcoind)
struct bitcoind *new_bitcoind(const tal_t *ctx, struct bitcoind *new_bitcoind(const tal_t *ctx,
struct lightningd *ld, struct lightningd *ld,
struct log *log) struct logger *log)
{ {
struct bitcoind *bitcoind = tal(ctx, struct bitcoind); struct bitcoind *bitcoind = tal(ctx, struct bitcoind);

View File

@ -17,7 +17,7 @@ struct bitcoin_block;
struct bitcoind { struct bitcoind {
/* Where to do logging. */ /* Where to do logging. */
struct log *log; struct logger *log;
/* Main lightningd structure */ /* Main lightningd structure */
struct lightningd *ld; struct lightningd *ld;
@ -56,7 +56,7 @@ struct filteredblock {
struct bitcoind *new_bitcoind(const tal_t *ctx, struct bitcoind *new_bitcoind(const tal_t *ctx,
struct lightningd *ld, struct lightningd *ld,
struct log *log); struct logger *log);
void bitcoind_estimate_fees(struct bitcoind *bitcoind, void bitcoind_estimate_fees(struct bitcoind *bitcoind,
void (*cb)(struct lightningd *ld, void (*cb)(struct lightningd *ld,

View File

@ -1229,7 +1229,7 @@ static void destroy_chain_topology(struct chain_topology *topo)
} }
} }
struct chain_topology *new_topology(struct lightningd *ld, struct log *log) struct chain_topology *new_topology(struct lightningd *ld, struct logger *log)
{ {
struct chain_topology *topo = tal(ld, struct chain_topology); struct chain_topology *topo = tal(ld, struct chain_topology);

View File

@ -117,7 +117,7 @@ struct chain_topology {
struct feerate_est *smoothed_feerates; struct feerate_est *smoothed_feerates;
/* Where to log things. */ /* Where to log things. */
struct log *log; struct logger *log;
/* What range of blocks do we have in our database? */ /* What range of blocks do we have in our database? */
u32 min_blockheight, max_blockheight; u32 min_blockheight, max_blockheight;
@ -243,7 +243,7 @@ void broadcast_tx_(struct chain_topology *topo,
bool (*refresh)(struct channel *, const struct bitcoin_tx **, void *), bool (*refresh)(struct channel *, const struct bitcoin_tx **, void *),
void *cbarg TAKES); void *cbarg TAKES);
struct chain_topology *new_topology(struct lightningd *ld, struct log *log); struct chain_topology *new_topology(struct lightningd *ld, struct logger *log);
void setup_topology(struct chain_topology *topology, void setup_topology(struct chain_topology *topology,
u32 min_blockheight, u32 max_blockheight); u32 min_blockheight, u32 max_blockheight);

View File

@ -211,10 +211,10 @@ struct channel *new_unsaved_channel(struct peer *peer,
memset(&channel->billboard, 0, sizeof(channel->billboard)); memset(&channel->billboard, 0, sizeof(channel->billboard));
channel->billboard.transient = tal_fmt(channel, "%s", channel->billboard.transient = tal_fmt(channel, "%s",
"Empty channel init'd"); "Empty channel init'd");
channel->log = new_log(channel, ld->log_book, channel->log = new_logger(channel, ld->log_book,
&peer->id, &peer->id,
"chan#%"PRIu64, "chan#%"PRIu64,
channel->unsaved_dbid); channel->unsaved_dbid);
channel->our_config.id = 0; channel->our_config.id = 0;
channel->open_attempt = NULL; channel->open_attempt = NULL;
@ -334,7 +334,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
enum channel_state state, enum channel_state state,
enum side opener, enum side opener,
/* NULL or stolen */ /* NULL or stolen */
struct log *log, struct logger *log,
const char *transient_billboard TAKES, const char *transient_billboard TAKES,
u8 channel_flags, u8 channel_flags,
bool req_confirmed_ins_local, bool req_confirmed_ins_local,
@ -436,11 +436,11 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
channel->scb = NULL; channel->scb = NULL;
if (!log) { if (!log) {
channel->log = new_log(channel, channel->log = new_logger(channel,
peer->ld->log_book, peer->ld->log_book,
&channel->peer->id, &channel->peer->id,
"chan#%"PRIu64, "chan#%"PRIu64,
dbid); dbid);
} else } else
channel->log = tal_steal(channel, log); channel->log = tal_steal(channel, log);
channel->req_confirmed_ins[LOCAL] = req_confirmed_ins_local; channel->req_confirmed_ins[LOCAL] = req_confirmed_ins_local;

View File

@ -110,7 +110,7 @@ struct channel {
struct subd *owner; struct subd *owner;
/* History */ /* History */
struct log *log; struct logger *log;
struct billboard billboard; struct billboard billboard;
/* Channel flags from opening message. */ /* Channel flags from opening message. */
@ -286,7 +286,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
enum channel_state state, enum channel_state state,
enum side opener, enum side opener,
/* NULL or stolen */ /* NULL or stolen */
struct log *log STEALS, struct logger *log STEALS,
const char *transient_billboard TAKES, const char *transient_billboard TAKES,
u8 channel_flags, u8 channel_flags,
bool req_confirmed_ins_local, bool req_confirmed_ins_local,

View File

@ -63,7 +63,7 @@ struct json_connection {
struct io_conn *conn; struct io_conn *conn;
/* Logging for this json connection. */ /* Logging for this json connection. */
struct log *log; struct logger *log;
/* The buffer (required to interpret tokens). */ /* The buffer (required to interpret tokens). */
char *buffer; char *buffer;
@ -149,7 +149,7 @@ static void destroy_jcon(struct json_connection *jcon)
tal_free(jcon->log); tal_free(jcon->log);
} }
struct log *command_log(struct command *cmd) struct logger *command_log(struct command *cmd)
{ {
if (cmd->jcon) if (cmd->jcon)
return cmd->jcon->log; return cmd->jcon->log;
@ -1143,8 +1143,8 @@ static struct io_plan *jcon_connected(struct io_conn *conn,
list_head_init(&jcon->commands); list_head_init(&jcon->commands);
/* We want to log on destruction, so we free this in destructor. */ /* We want to log on destruction, so we free this in destructor. */
jcon->log = new_log(ld->log_book, ld->log_book, NULL, "jsonrpc#%i", jcon->log = new_logger(ld->log_book, ld->log_book, NULL, "jsonrpc#%i",
io_conn_fd(conn)); io_conn_fd(conn));
tal_add_destructor(jcon, destroy_jcon); tal_add_destructor(jcon, destroy_jcon);
@ -1381,7 +1381,7 @@ void jsonrpc_notification_end(struct jsonrpc_notification *n)
struct jsonrpc_request *jsonrpc_request_start_( struct jsonrpc_request *jsonrpc_request_start_(
const tal_t *ctx, const char *method, const tal_t *ctx, const char *method,
const char *id_prefix, bool id_as_string, struct log *log, const char *id_prefix, bool id_as_string, struct logger *log,
bool add_header, bool add_header,
void (*notify_cb)(const char *buffer, void (*notify_cb)(const char *buffer,
const jsmntok_t *methodtok, const jsmntok_t *methodtok,

View File

@ -142,7 +142,7 @@ struct command_result *command_raw_complete(struct command *cmd,
struct json_stream *result); struct json_stream *result);
/* Logging point to use for this command (usually, the JSON connection). */ /* Logging point to use for this command (usually, the JSON connection). */
struct log *command_log(struct command *cmd); struct logger *command_log(struct command *cmd);
/* To return if param() fails. */ /* To return if param() fails. */
extern struct command_result *command_param_failed(void) extern struct command_result *command_param_failed(void)
@ -259,7 +259,7 @@ struct jsonrpc_request *jsonrpc_request_start_(
const tal_t *ctx, const char *method, const tal_t *ctx, const char *method,
const char *id_prefix TAKES, const char *id_prefix TAKES,
bool id_as_string, bool id_as_string,
struct log *log, bool add_header, struct logger *log, bool add_header,
void (*notify_cb)(const char *buffer, void (*notify_cb)(const char *buffer,
const jsmntok_t *idtok, const jsmntok_t *idtok,
const jsmntok_t *methodtok, const jsmntok_t *methodtok,

View File

@ -198,7 +198,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
/*~ Note the tal context arg (by convention, the first argument to any /*~ Note the tal context arg (by convention, the first argument to any
* allocation function): ld->log will be implicitly freed when ld * allocation function): ld->log will be implicitly freed when ld
* is. */ * is. */
ld->log = new_log(ld, ld->log_book, NULL, "lightningd"); ld->log = new_logger(ld, ld->log_book, NULL, "lightningd");
ld->logfiles = NULL; ld->logfiles = NULL;
/*~ We explicitly set these to NULL: if they're still NULL after option /*~ We explicitly set these to NULL: if they're still NULL after option

View File

@ -134,10 +134,10 @@ struct lightningd {
/* Where each configuration setting came from */ /* Where each configuration setting came from */
struct configvar **configvars; struct configvar **configvars;
/* This log_book is owned by all the struct logs */ /* This log_book is owned by all the struct loggers */
struct log_book *log_book; struct log_book *log_book;
/* Log for general stuff. */ /* Log for general stuff. */
struct log *log; struct logger *log;
const char **logfiles; const char **logfiles;
/* This is us. */ /* This is us. */

View File

@ -20,7 +20,7 @@
#define DEFAULT_LOGLEVEL LOG_INFORM #define DEFAULT_LOGLEVEL LOG_INFORM
/* Once we're up and running, this is set up. */ /* Once we're up and running, this is set up. */
struct log *crashlog; struct logger *crashlog;
struct print_filter { struct print_filter {
struct list_node list; struct list_node list;
@ -56,8 +56,8 @@ struct log_book {
struct node_id_map *cache; struct node_id_map *cache;
}; };
struct log { struct logger {
struct log_book *lr; struct log_book *log_book;
const struct node_id *default_node_id; const struct node_id *default_node_id;
struct log_prefix *prefix; struct log_prefix *prefix;
@ -266,58 +266,58 @@ static void destroy_log_book(struct log_book *log)
struct log_book *new_log_book(struct lightningd *ld, size_t max_mem) struct log_book *new_log_book(struct lightningd *ld, size_t max_mem)
{ {
struct log_book *lr = tal_linkable(tal(NULL, struct log_book)); struct log_book *log_book = tal_linkable(tal(NULL, struct log_book));
/* Give a reasonable size for memory limit! */ /* Give a reasonable size for memory limit! */
assert(max_mem > sizeof(struct log) * 2); assert(max_mem > sizeof(struct logger) * 2);
lr->mem_used = 0; log_book->mem_used = 0;
lr->num_entries = 0; log_book->num_entries = 0;
lr->max_mem = max_mem; log_book->max_mem = max_mem;
lr->outfiles = NULL; log_book->outfiles = NULL;
lr->default_print_level = NULL; log_book->default_print_level = NULL;
/* We have to allocate this, since we tal_free it on resetting */ /* We have to allocate this, since we tal_free it on resetting */
lr->prefix = tal_strdup(lr, ""); log_book->prefix = tal_strdup(log_book, "");
list_head_init(&lr->print_filters); list_head_init(&log_book->print_filters);
lr->init_time = time_now(); log_book->init_time = time_now();
lr->ld = ld; log_book->ld = ld;
lr->cache = tal(lr, struct node_id_map); log_book->cache = tal(log_book, struct node_id_map);
node_id_map_init(lr->cache); node_id_map_init(log_book->cache);
lr->log = tal_arr(lr, struct log_entry, 128); log_book->log = tal_arr(log_book, struct log_entry, 128);
lr->print_timestamps = true; log_book->print_timestamps = true;
tal_add_destructor(lr, destroy_log_book); tal_add_destructor(log_book, destroy_log_book);
return lr; return log_book;
} }
static enum log_level filter_level(struct log_book *lr, static enum log_level filter_level(struct log_book *log_book,
const struct log_prefix *lp, const struct log_prefix *lp,
const struct node_id *node_id) const struct node_id *node_id)
{ {
struct print_filter *i; struct print_filter *i;
const char *node_id_str = node_id ? node_id_to_hexstr(tmpctx, node_id) : ""; const char *node_id_str = node_id ? node_id_to_hexstr(tmpctx, node_id) : "";
assert(lr->default_print_level != NULL); assert(log_book->default_print_level != NULL);
list_for_each(&lr->print_filters, i, list) { list_for_each(&log_book->print_filters, i, list) {
if (strstr(lp->prefix, i->prefix) || strstr(node_id_str, i->prefix)) if (strstr(lp->prefix, i->prefix) || strstr(node_id_str, i->prefix))
return i->level; return i->level;
} }
return *lr->default_print_level; return *log_book->default_print_level;
} }
/* With different entry points */ /* With different entry points */
struct log * struct logger *
new_log(const tal_t *ctx, struct log_book *record, new_logger(const tal_t *ctx, struct log_book *log_book,
const struct node_id *default_node_id, const struct node_id *default_node_id,
const char *fmt, ...) const char *fmt, ...)
{ {
struct log *log = tal(ctx, struct log); struct logger *log = tal(ctx, struct logger);
va_list ap; va_list ap;
log->lr = tal_link(log, record); log->log_book = tal_link(log, log_book);
va_start(ap, fmt); va_start(ap, fmt);
/* Owned by the log book itself, since it can be referenced /* Owned by the log book itself, since it can be referenced
* by log entries, too */ * by log entries, too */
log->prefix = log_prefix_new(log->lr, take(tal_vfmt(NULL, fmt, ap))); log->prefix = log_prefix_new(log->log_book, take(tal_vfmt(NULL, fmt, ap)));
va_end(ap); va_end(ap);
log->default_node_id = tal_dup_or_null(log, struct node_id, log->default_node_id = tal_dup_or_null(log, struct node_id,
default_node_id); default_node_id);
@ -327,54 +327,54 @@ new_log(const tal_t *ctx, struct log_book *record,
return log; return log;
} }
const char *log_prefix(const struct log *log) const char *log_prefix(const struct logger *log)
{ {
return log->prefix->prefix; return log->prefix->prefix;
} }
enum log_level log_print_level(struct log *log, const struct node_id *node_id) enum log_level log_print_level(struct logger *log, const struct node_id *node_id)
{ {
if (!log->print_level) { if (!log->print_level) {
/* Not set globally yet? Print UNUSUAL / BROKEN messages only */ /* Not set globally yet? Print UNUSUAL / BROKEN messages only */
if (!log->lr->default_print_level) if (!log->log_book->default_print_level)
return LOG_UNUSUAL; return LOG_UNUSUAL;
log->print_level = tal(log, enum log_level); log->print_level = tal(log, enum log_level);
*log->print_level = filter_level(log->lr, log->prefix, node_id); *log->print_level = filter_level(log->log_book, log->prefix, node_id);
} }
return *log->print_level; return *log->print_level;
} }
/* This may move entry! */ /* This may move entry! */
static void add_entry(struct log *log, struct log_entry **l) static void add_entry(struct logger *log, struct log_entry **l)
{ {
log->lr->mem_used += mem_used(*l); log->log_book->mem_used += mem_used(*l);
log->lr->num_entries++; log->log_book->num_entries++;
if (log->lr->mem_used > log->lr->max_mem) { if (log->log_book->mem_used > log->log_book->max_mem) {
size_t old_mem = log->lr->mem_used, deleted; size_t old_mem = log->log_book->mem_used, deleted;
deleted = prune_log(log->lr); deleted = prune_log(log->log_book);
/* Will have moved, but will be last entry. */ /* Will have moved, but will be last entry. */
*l = &log->lr->log[log->lr->num_entries-1]; *l = &log->log_book->log[log->log_book->num_entries-1];
log_debug(log, "Log pruned %zu entries (mem %zu -> %zu)", log_debug(log, "Log pruned %zu entries (mem %zu -> %zu)",
deleted, old_mem, log->lr->mem_used); deleted, old_mem, log->log_book->mem_used);
} }
} }
static void destroy_node_id_cache(struct node_id_cache *nc, struct log_book *lr) static void destroy_node_id_cache(struct node_id_cache *nc, struct log_book *log_book)
{ {
node_id_map_del(lr->cache, nc); node_id_map_del(log_book->cache, nc);
} }
static struct log_entry *new_log_entry(struct log *log, enum log_level level, static struct log_entry *new_log_entry(struct logger *log, enum log_level level,
const struct node_id *node_id) const struct node_id *node_id)
{ {
struct log_entry *l; struct log_entry *l;
if (log->lr->num_entries == tal_count(log->lr->log)) if (log->log_book->num_entries == tal_count(log->log_book->log))
tal_resize(&log->lr->log, tal_count(log->lr->log) * 2); tal_resize(&log->log_book->log, tal_count(log->log_book->log) * 2);
l = &log->lr->log[log->lr->num_entries]; l = &log->log_book->log[log->log_book->num_entries];
l->time = time_now(); l->time = time_now();
l->level = level; l->level = level;
l->skipped = 0; l->skipped = 0;
@ -383,14 +383,14 @@ static struct log_entry *new_log_entry(struct log *log, enum log_level level,
if (!node_id) if (!node_id)
node_id = log->default_node_id; node_id = log->default_node_id;
if (node_id) { if (node_id) {
l->nc = node_id_map_get(log->lr->cache, node_id); l->nc = node_id_map_get(log->log_book->cache, node_id);
if (!l->nc) { if (!l->nc) {
l->nc = tal(log->lr->cache, struct node_id_cache); l->nc = tal(log->log_book->cache, struct node_id_cache);
l->nc->count = 0; l->nc->count = 0;
l->nc->node_id = *node_id; l->nc->node_id = *node_id;
node_id_map_add(log->lr->cache, l->nc); node_id_map_add(log->log_book->cache, l->nc);
tal_add_destructor2(l->nc, destroy_node_id_cache, tal_add_destructor2(l->nc, destroy_node_id_cache,
log->lr); log->log_book);
} }
l->nc->count++; l->nc->count++;
} else } else
@ -399,18 +399,18 @@ static struct log_entry *new_log_entry(struct log *log, enum log_level level,
return l; return l;
} }
static void maybe_print(struct log *log, const struct log_entry *l) static void maybe_print(struct logger *log, const struct log_entry *l)
{ {
if (l->level >= log_print_level(log, l->nc ? &l->nc->node_id : NULL)) if (l->level >= log_print_level(log, l->nc ? &l->nc->node_id : NULL))
log_to_files(log->lr->prefix, log->prefix->prefix, l->level, log_to_files(log->log_book->prefix, log->prefix->prefix, l->level,
l->nc ? &l->nc->node_id : NULL, l->nc ? &l->nc->node_id : NULL,
&l->time, l->log, &l->time, l->log,
l->io, tal_bytelen(l->io), l->io, tal_bytelen(l->io),
log->lr->print_timestamps, log->log_book->print_timestamps,
log->lr->outfiles); log->log_book->outfiles);
} }
void logv(struct log *log, enum log_level level, void logv(struct logger *log, enum log_level level,
const struct node_id *node_id, const struct node_id *node_id,
bool call_notifier, bool call_notifier,
const char *fmt, va_list ap) const char *fmt, va_list ap)
@ -435,12 +435,12 @@ void logv(struct log *log, enum log_level level,
add_entry(log, &l); add_entry(log, &l);
if (call_notifier) if (call_notifier)
notify_warning(log->lr->ld, l); notify_warning(log->log_book->ld, l);
errno = save_errno; errno = save_errno;
} }
void log_io(struct log *log, enum log_level dir, void log_io(struct logger *log, enum log_level dir,
const struct node_id *node_id, const struct node_id *node_id,
const char *str TAKES, const char *str TAKES,
const void *data TAKES, size_t len) const void *data TAKES, size_t len)
@ -452,12 +452,12 @@ void log_io(struct log *log, enum log_level dir,
/* Print first, in case we need to truncate. */ /* Print first, in case we need to truncate. */
if (l->level >= log_print_level(log, node_id)) if (l->level >= log_print_level(log, node_id))
log_to_files(log->lr->prefix, log->prefix->prefix, l->level, log_to_files(log->log_book->prefix, log->prefix->prefix, l->level,
l->nc ? &l->nc->node_id : NULL, l->nc ? &l->nc->node_id : NULL,
&l->time, str, &l->time, str,
data, len, data, len,
log->lr->print_timestamps, log->log_book->print_timestamps,
log->lr->outfiles); log->log_book->outfiles);
/* Save a tal header, by using raw malloc. */ /* Save a tal header, by using raw malloc. */
l->log = strdup(str); l->log = strdup(str);
@ -465,20 +465,20 @@ void log_io(struct log *log, enum log_level dir,
tal_free(str); tal_free(str);
/* Don't immediately fill buffer with giant IOs */ /* Don't immediately fill buffer with giant IOs */
if (len > log->lr->max_mem / 64) { if (len > log->log_book->max_mem / 64) {
l->skipped++; l->skipped++;
len = log->lr->max_mem / 64; len = log->log_book->max_mem / 64;
} }
/* FIXME: We could save 4 pointers by using a raw allow, but saving /* FIXME: We could save 4 pointers by using a raw allow, but saving
* the length. */ * the length. */
l->io = tal_dup_arr(log->lr, u8, data, len, 0); l->io = tal_dup_arr(log->log_book, u8, data, len, 0);
add_entry(log, &l); add_entry(log, &l);
errno = save_errno; errno = save_errno;
} }
void log_(struct log *log, enum log_level level, void log_(struct logger *log, enum log_level level,
const struct node_id *node_id, const struct node_id *node_id,
bool call_notifier, bool call_notifier,
const char *fmt, ...) const char *fmt, ...)
@ -490,8 +490,8 @@ void log_(struct log *log, enum log_level level,
va_end(ap); va_end(ap);
} }
#define log_each_line(lr, func, arg) \ #define log_each_line(log_book, func, arg) \
log_each_line_((lr), \ log_each_line_((log_book), \
typesafe_cb_preargs(void, void *, (func), (arg), \ typesafe_cb_preargs(void, void *, (func), (arg), \
unsigned int, \ unsigned int, \
struct timerel, \ struct timerel, \
@ -501,7 +501,7 @@ void log_(struct log *log, enum log_level level,
const char *, \ const char *, \
const u8 *), (arg)) const u8 *), (arg))
static void log_each_line_(const struct log_book *lr, static void log_each_line_(const struct log_book *log_book,
void (*func)(unsigned int skipped, void (*func)(unsigned int skipped,
struct timerel time, struct timerel time,
enum log_level level, enum log_level level,
@ -512,10 +512,10 @@ static void log_each_line_(const struct log_book *lr,
void *arg), void *arg),
void *arg) void *arg)
{ {
for (size_t i = 0; i < lr->num_entries; i++) { for (size_t i = 0; i < log_book->num_entries; i++) {
const struct log_entry *l = &lr->log[i]; const struct log_entry *l = &log_book->log[i];
func(l->skipped, time_between(l->time, lr->init_time), func(l->skipped, time_between(l->time, log_book->init_time),
l->level, l->nc ? &l->nc->node_id : NULL, l->level, l->nc ? &l->nc->node_id : NULL,
l->prefix->prefix, l->log, l->io, arg); l->prefix->prefix, l->log, l->io, arg);
} }
@ -574,7 +574,7 @@ static void log_one_line(unsigned int skipped,
data->prefix = "\n"; data->prefix = "\n";
} }
char *opt_log_level(const char *arg, struct log *log) char *opt_log_level(const char *arg, struct logger *log)
{ {
enum log_level level; enum log_level level;
int len; int len;
@ -584,34 +584,34 @@ char *opt_log_level(const char *arg, struct log *log)
return tal_fmt(tmpctx, "unknown log level %.*s", len, arg); return tal_fmt(tmpctx, "unknown log level %.*s", len, arg);
if (arg[len]) { if (arg[len]) {
struct print_filter *f = tal(log->lr, struct print_filter); struct print_filter *f = tal(log->log_book, struct print_filter);
f->prefix = arg + len + 1; f->prefix = arg + len + 1;
f->level = level; f->level = level;
list_add_tail(&log->lr->print_filters, &f->list); list_add_tail(&log->log_book->print_filters, &f->list);
} else { } else {
tal_free(log->lr->default_print_level); tal_free(log->log_book->default_print_level);
log->lr->default_print_level = tal(log->lr, enum log_level); log->log_book->default_print_level = tal(log->log_book, enum log_level);
*log->lr->default_print_level = level; *log->log_book->default_print_level = level;
} }
return NULL; return NULL;
} }
void json_add_opt_log_levels(struct json_stream *response, struct log *log) void json_add_opt_log_levels(struct json_stream *response, struct logger *log)
{ {
struct print_filter *i; struct print_filter *i;
list_for_each(&log->lr->print_filters, i, list) { list_for_each(&log->log_book->print_filters, i, list) {
json_add_str_fmt(response, "log-level", "%s:%s", json_add_str_fmt(response, "log-level", "%s:%s",
log_level_name(i->level), i->prefix); log_level_name(i->level), i->prefix);
} }
} }
static bool show_log_level(char *buf, size_t len, const struct log *log) static bool show_log_level(char *buf, size_t len, const struct logger *log)
{ {
enum log_level l; enum log_level l;
if (log->lr->default_print_level) if (log->log_book->default_print_level)
l = *log->lr->default_print_level; l = *log->log_book->default_print_level;
else else
l = DEFAULT_LOGLEVEL; l = DEFAULT_LOGLEVEL;
strncpy(buf, log_level_name(l), len); strncpy(buf, log_level_name(l), len);
@ -648,12 +648,12 @@ static struct io_plan *setup_read(struct io_conn *conn, struct lightningd *ld);
static struct io_plan *rotate_log(struct io_conn *conn, struct lightningd *ld) static struct io_plan *rotate_log(struct io_conn *conn, struct lightningd *ld)
{ {
log_info(ld->log, "Ending log due to SIGHUP"); log_info(ld->log, "Ending log due to SIGHUP");
for (size_t i = 0; i < tal_count(ld->log->lr->outfiles); i++) { for (size_t i = 0; i < tal_count(ld->log->log_book->outfiles); i++) {
if (streq(ld->logfiles[i], "-")) if (streq(ld->logfiles[i], "-"))
continue; continue;
fclose(ld->log->lr->outfiles[i]); fclose(ld->log->log_book->outfiles[i]);
ld->log->lr->outfiles[i] = fopen(ld->logfiles[i], "a"); ld->log->log_book->outfiles[i] = fopen(ld->logfiles[i], "a");
if (!ld->log->lr->outfiles[i]) if (!ld->log->log_book->outfiles[i])
err(1, "failed to reopen log file %s", ld->logfiles[i]); err(1, "failed to reopen log file %s", ld->logfiles[i]);
} }
@ -709,7 +709,7 @@ char *arg_log_to_file(const char *arg, struct lightningd *ld)
if (!ld->logfiles) { if (!ld->logfiles) {
setup_log_rotation(ld); setup_log_rotation(ld);
ld->logfiles = tal_arr(ld, const char *, 0); ld->logfiles = tal_arr(ld, const char *, 0);
ld->log->lr->outfiles = tal_arr(ld->log->lr, FILE *, 0); ld->log->log_book->outfiles = tal_arr(ld->log->log_book, FILE *, 0);
} }
if (streq(arg, "-")) if (streq(arg, "-"))
@ -721,7 +721,7 @@ char *arg_log_to_file(const char *arg, struct lightningd *ld)
} }
tal_arr_expand(&ld->logfiles, tal_strdup(ld->logfiles, arg)); tal_arr_expand(&ld->logfiles, tal_strdup(ld->logfiles, arg));
tal_arr_expand(&ld->log->lr->outfiles, outf); tal_arr_expand(&ld->log->log_book->outfiles, outf);
/* For convenience make a block of empty lines just like Bitcoin Core */ /* For convenience make a block of empty lines just like Bitcoin Core */
size = ftell(outf); size = ftell(outf);
@ -739,7 +739,7 @@ void opt_register_logging(struct lightningd *ld)
"log level (io, debug, info, unusual, broken) [:prefix]"); "log level (io, debug, info, unusual, broken) [:prefix]");
clnopt_witharg("--log-timestamps", OPT_EARLY|OPT_SHOWBOOL, clnopt_witharg("--log-timestamps", OPT_EARLY|OPT_SHOWBOOL,
opt_set_bool_arg, opt_show_bool, opt_set_bool_arg, opt_show_bool,
&ld->log->lr->print_timestamps, &ld->log->log_book->print_timestamps,
"prefix log messages with timestamp"); "prefix log messages with timestamp");
opt_register_early_arg("--log-prefix", arg_log_prefix, show_log_prefix, opt_register_early_arg("--log-prefix", arg_log_prefix, show_log_prefix,
ld->log_book, ld->log_book,
@ -750,25 +750,25 @@ void opt_register_logging(struct lightningd *ld)
"Also log to file (- for stdout)"); "Also log to file (- for stdout)");
} }
void logging_options_parsed(struct log_book *lr) void logging_options_parsed(struct log_book *log_book)
{ {
/* If they didn't set an explicit level, set to info */ /* If they didn't set an explicit level, set to info */
if (!lr->default_print_level) { if (!log_book->default_print_level) {
lr->default_print_level = tal(lr, enum log_level); log_book->default_print_level = tal(log_book, enum log_level);
*lr->default_print_level = DEFAULT_LOGLEVEL; *log_book->default_print_level = DEFAULT_LOGLEVEL;
} }
/* Catch up, since before we were only printing BROKEN msgs */ /* Catch up, since before we were only printing BROKEN msgs */
for (size_t i = 0; i < lr->num_entries; i++) { for (size_t i = 0; i < log_book->num_entries; i++) {
const struct log_entry *l = &lr->log[i]; const struct log_entry *l = &log_book->log[i];
if (l->level >= filter_level(lr, l->prefix, NULL)) if (l->level >= filter_level(log_book, l->prefix, NULL))
log_to_files(lr->prefix, l->prefix->prefix, l->level, log_to_files(log_book->prefix, l->prefix->prefix, l->level,
l->nc ? &l->nc->node_id : NULL, l->nc ? &l->nc->node_id : NULL,
&l->time, l->log, &l->time, l->log,
l->io, tal_bytelen(l->io), l->io, tal_bytelen(l->io),
lr->print_timestamps, log_book->print_timestamps,
lr->outfiles); log_book->outfiles);
} }
} }
@ -784,26 +784,26 @@ void log_backtrace_print(const char *fmt, ...)
va_end(ap); va_end(ap);
} }
static void log_dump_to_file(int fd, const struct log_book *lr) static void log_dump_to_file(int fd, const struct log_book *log_book)
{ {
char buf[100]; char buf[100];
int len; int len;
struct log_data data; struct log_data data;
time_t start; time_t start;
if (lr->num_entries == 0) { if (log_book->num_entries == 0) {
write_all(fd, "0 bytes:\n\n", strlen("0 bytes:\n\n")); write_all(fd, "0 bytes:\n\n", strlen("0 bytes:\n\n"));
return; return;
} }
start = lr->init_time.ts.tv_sec; start = log_book->init_time.ts.tv_sec;
len = snprintf(buf, sizeof(buf), "%zu bytes, %s", lr->mem_used, ctime(&start)); len = snprintf(buf, sizeof(buf), "%zu bytes, %s", log_book->mem_used, ctime(&start));
write_all(fd, buf, len); write_all(fd, buf, len);
/* ctime includes \n... WTF? */ /* ctime includes \n... WTF? */
data.prefix = ""; data.prefix = "";
data.fd = fd; data.fd = fd;
log_each_line(lr, log_one_line, &data); log_each_line(log_book, log_one_line, &data);
write_all(fd, "\n\n", strlen("\n\n")); write_all(fd, "\n\n", strlen("\n\n"));
} }
@ -831,7 +831,7 @@ void log_backtrace_exit(void)
/* Dump entire log. */ /* Dump entire log. */
if (fd >= 0) { if (fd >= 0) {
log_dump_to_file(fd, crashlog->lr); log_dump_to_file(fd, crashlog->log_book);
close(fd); close(fd);
fprintf(stderr, "Log dumped in %s\n", logfile); fprintf(stderr, "Log dumped in %s\n", logfile);
} }
@ -927,7 +927,7 @@ static void log_to_json(unsigned int skipped,
} }
void json_add_log(struct json_stream *response, void json_add_log(struct json_stream *response,
const struct log_book *lr, const struct log_book *log_book,
const struct node_id *node_id, const struct node_id *node_id,
enum log_level minlevel) enum log_level minlevel)
{ {
@ -939,7 +939,7 @@ void json_add_log(struct json_stream *response,
info.node_id = node_id; info.node_id = node_id;
json_array_start(info.response, "log"); json_array_start(info.response, "log");
log_each_line(lr, log_to_json, &info); log_each_line(log_book, log_to_json, &info);
add_skipped(&info); add_skipped(&info);
json_array_end(info.response); json_array_end(info.response);
} }
@ -966,7 +966,7 @@ static struct command_result *json_getlog(struct command *cmd,
{ {
struct json_stream *response; struct json_stream *response;
enum log_level *minlevel; enum log_level *minlevel;
struct log_book *lr = cmd->ld->log_book; struct log_book *log_book = cmd->ld->log_book;
if (!param(cmd, buffer, params, if (!param(cmd, buffer, params,
p_opt_def("level", param_loglevel, &minlevel, LOG_INFORM), p_opt_def("level", param_loglevel, &minlevel, LOG_INFORM),
@ -976,10 +976,10 @@ static struct command_result *json_getlog(struct command *cmd,
response = json_stream_success(cmd); response = json_stream_success(cmd);
/* Suppress logging for this stream, to not bloat io logs */ /* Suppress logging for this stream, to not bloat io logs */
json_stream_log_suppress_for_cmd(response, cmd); json_stream_log_suppress_for_cmd(response, cmd);
json_add_time(response, "created_at", lr->init_time.ts); json_add_time(response, "created_at", log_book->init_time.ts);
json_add_num(response, "bytes_used", (unsigned int)lr->mem_used); json_add_num(response, "bytes_used", (unsigned int)log_book->mem_used);
json_add_num(response, "bytes_max", (unsigned int)lr->max_mem); json_add_num(response, "bytes_max", (unsigned int)log_book->max_mem);
json_add_log(response, lr, NULL, *minlevel); json_add_log(response, log_book, NULL, *minlevel);
return command_success(cmd, response); return command_success(cmd, response);
} }

View File

@ -11,47 +11,47 @@ struct lightningd;
struct node_id; struct node_id;
struct timerel; struct timerel;
/* We can have a single log book, with multiple logs in it: it's freed /* We can have a single log book, with multiple loggers writing to it: it's freed
* by the last struct log itself. */ * by the last struct logger itself. */
struct log_book *new_log_book(struct lightningd *ld, size_t max_mem); struct log_book *new_log_book(struct lightningd *ld, size_t max_mem);
/* With different entry points */ /* With different entry points */
struct log *new_log(const tal_t *ctx, struct log_book *record, struct logger *new_logger(const tal_t *ctx, struct log_book *record,
const struct node_id *default_node_id, const struct node_id *default_node_id,
const char *fmt, ...) PRINTF_FMT(4,5); const char *fmt, ...) PRINTF_FMT(4,5);
#define log_debug(log, ...) log_((log), LOG_DBG, NULL, false, __VA_ARGS__) #define log_debug(logger, ...) log_((logger), LOG_DBG, NULL, false, __VA_ARGS__)
#define log_info(log, ...) log_((log), LOG_INFORM, NULL, false, __VA_ARGS__) #define log_info(logger, ...) log_((logger), LOG_INFORM, NULL, false, __VA_ARGS__)
#define log_unusual(log, ...) log_((log), LOG_UNUSUAL, NULL, true, __VA_ARGS__) #define log_unusual(logger, ...) log_((logger), LOG_UNUSUAL, NULL, true, __VA_ARGS__)
#define log_broken(log, ...) log_((log), LOG_BROKEN, NULL, true, __VA_ARGS__) #define log_broken(logger, ...) log_((logger), LOG_BROKEN, NULL, true, __VA_ARGS__)
#define log_peer_debug(log, nodeid, ...) log_((log), LOG_DBG, nodeid, false, __VA_ARGS__) #define log_peer_debug(logger, nodeid, ...) log_((logger), LOG_DBG, nodeid, false, __VA_ARGS__)
#define log_peer_info(log, nodeid, ...) log_((log), LOG_INFORM, nodeid, false, __VA_ARGS__) #define log_peer_info(logger, nodeid, ...) log_((logger), LOG_INFORM, nodeid, false, __VA_ARGS__)
#define log_peer_unusual(log, nodeid, ...) log_((log), LOG_UNUSUAL, nodeid, true, __VA_ARGS__) #define log_peer_unusual(logger, nodeid, ...) log_((logger), LOG_UNUSUAL, nodeid, true, __VA_ARGS__)
#define log_peer_broken(log, nodeid, ...) log_((log), LOG_BROKEN, nodeid, true, __VA_ARGS__) #define log_peer_broken(logger, nodeid, ...) log_((logger), LOG_BROKEN, nodeid, true, __VA_ARGS__)
void log_io(struct log *log, enum log_level dir, void log_io(struct logger *logger, enum log_level dir,
const struct node_id *node_id, const struct node_id *node_id,
const char *comment, const char *comment,
const void *data, size_t len); const void *data, size_t len);
void log_(struct log *log, enum log_level level, void log_(struct logger *logger, enum log_level level,
const struct node_id *node_id, const struct node_id *node_id,
bool call_notifier, bool call_notifier,
const char *fmt, ...) const char *fmt, ...)
PRINTF_FMT(5,6); PRINTF_FMT(5,6);
void logv(struct log *log, enum log_level level, const struct node_id *node_id, void logv(struct logger *logger, enum log_level level, const struct node_id *node_id,
bool call_notifier, const char *fmt, va_list ap); bool call_notifier, const char *fmt, va_list ap);
const char *log_prefix(const struct log *log); const char *log_prefix(const struct logger *logger);
enum log_level log_print_level(struct log *log, const struct node_id *node_id); enum log_level log_print_level(struct logger *log, const struct node_id *node_id);
void opt_register_logging(struct lightningd *ld); void opt_register_logging(struct lightningd *ld);
char *arg_log_to_file(const char *arg, struct lightningd *ld); char *arg_log_to_file(const char *arg, struct lightningd *ld);
/* Once this is set, we dump fatal with a backtrace to this log */ /* Once this is set, we dump fatal with a backtrace to this log */
extern struct log *crashlog; extern struct logger *crashlog;
void NORETURN PRINTF_FMT(1,2) fatal(const char *fmt, ...); void NORETURN PRINTF_FMT(1,2) fatal(const char *fmt, ...);
void NORETURN fatal_vfmt(const char *fmt, va_list ap); void NORETURN fatal_vfmt(const char *fmt, va_list ap);
@ -60,7 +60,7 @@ void log_backtrace_exit(void);
/* Adds an array showing log entries */ /* Adds an array showing log entries */
void json_add_log(struct json_stream *result, void json_add_log(struct json_stream *result,
const struct log_book *lr, const struct log_book *log_book,
const struct node_id *node_id, const struct node_id *node_id,
enum log_level minlevel); enum log_level minlevel);
@ -89,7 +89,7 @@ struct log_entry {
}; };
/* For options.c's listconfig */ /* For options.c's listconfig */
char *opt_log_level(const char *arg, struct log *log); char *opt_log_level(const char *arg, struct logger *logger);
void json_add_opt_log_levels(struct json_stream *response, struct log *log); void json_add_opt_log_levels(struct json_stream *response, struct logger *logger);
void logging_options_parsed(struct log_book *lr); void logging_options_parsed(struct log_book *log_book);
#endif /* LIGHTNING_LIGHTNINGD_LOG_H */ #endif /* LIGHTNING_LIGHTNINGD_LOG_H */

View File

@ -2,7 +2,7 @@
#include <common/status_wiregen.h> #include <common/status_wiregen.h>
#include <lightningd/log_status.h> #include <lightningd/log_status.h>
bool log_status_msg(struct log *log, bool log_status_msg(struct logger *log,
const struct node_id *node_id, const struct node_id *node_id,
const u8 *msg) const u8 *msg)
{ {

View File

@ -4,7 +4,7 @@
#include <lightningd/log.h> #include <lightningd/log.h>
/* Returns true (and writes it to log) if it's a status_log message. */ /* Returns true (and writes it to log) if it's a status_log message. */
bool log_status_msg(struct log *log, bool log_status_msg(struct logger *log,
const struct node_id *node_id, const struct node_id *node_id,
const u8 *msg); const u8 *msg);

View File

@ -47,8 +47,8 @@ new_uncommitted_channel(struct peer *peer)
uc->transient_billboard = NULL; uc->transient_billboard = NULL;
uc->dbid = wallet_get_channel_dbid(ld->wallet); uc->dbid = wallet_get_channel_dbid(ld->wallet);
uc->log = new_log(uc, ld->log_book, &uc->peer->id, uc->log = new_logger(uc, ld->log_book, &uc->peer->id,
"chan#%"PRIu64, uc->dbid); "chan#%"PRIu64, uc->dbid);
uc->fc = NULL; uc->fc = NULL;
uc->our_config.id = 0; uc->our_config.id = 0;

View File

@ -14,7 +14,7 @@ struct basepoints;
struct channel_config; struct channel_config;
struct command; struct command;
struct lightningd; struct lightningd;
struct log; struct logger;
struct peer; struct peer;
struct wally_tx; struct wally_tx;
@ -32,7 +32,7 @@ struct uncommitted_channel {
struct channel_id cid; struct channel_id cid;
/* For logging */ /* For logging */
struct log *log; struct logger *log;
/* Openingd can tell us stuff. */ /* Openingd can tell us stuff. */
const char *transient_billboard; const char *transient_billboard;

View File

@ -415,7 +415,7 @@ remote_routing_failure(const tal_t *ctx,
const struct wallet_payment *payment, const struct wallet_payment *payment,
const u8 *failuremsg, const u8 *failuremsg,
int origin_index, int origin_index,
struct log *log, struct logger *log,
enum jsonrpc_errcode *pay_errcode) enum jsonrpc_errcode *pay_errcode)
{ {
enum onion_wire failcode = fromwire_peektype(failuremsg); enum onion_wire failcode = fromwire_peektype(failuremsg);

View File

@ -77,8 +77,7 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
struct plugins *p; struct plugins *p;
p = tal(ctx, struct plugins); p = tal(ctx, struct plugins);
list_head_init(&p->plugins); list_head_init(&p->plugins);
p->log_book = log_book; p->log = new_logger(p, log_book, NULL, "plugin-manager");
p->log = new_log(p, log_book, NULL, "plugin-manager");
p->ld = ld; p->ld = ld;
p->startup = true; p->startup = true;
p->plugin_cmds = tal_arr(p, struct plugin_command *, 0); p->plugin_cmds = tal_arr(p, struct plugin_command *, 0);
@ -299,7 +298,7 @@ struct plugin *plugin_register(struct plugins *plugins, const char* path TAKES,
p->non_numeric_ids = false; p->non_numeric_ids = false;
p->index = plugins->plugin_idx++; p->index = plugins->plugin_idx++;
p->log = new_log(p, plugins->log_book, NULL, "plugin-%s", p->shortname); p->log = new_logger(p, plugins->ld->log_book, NULL, "plugin-%s", p->shortname);
p->methods = tal_arr(p, const char *, 0); p->methods = tal_arr(p, const char *, 0);
list_head_init(&p->plugin_opts); list_head_init(&p->plugin_opts);
@ -2327,7 +2326,7 @@ void *plugins_exclusive_loop(struct plugin **plugins)
return ret; return ret;
} }
struct log *plugin_get_log(struct plugin *plugin) struct logger *plugin_get_logger(struct plugin *plugin)
{ {
return plugin->log; return plugin->log;
} }

View File

@ -59,7 +59,7 @@ struct plugin {
* freeing once empty. */ * freeing once empty. */
struct json_stream **js_arr; struct json_stream **js_arr;
struct log *log; struct logger *log;
/* List of options that this plugin registered */ /* List of options that this plugin registered */
struct list_head plugin_opts; struct list_head plugin_opts;
@ -104,8 +104,7 @@ struct plugins {
/* Currently pending requests by their request ID */ /* Currently pending requests by their request ID */
STRMAP(struct jsonrpc_request *) pending_requests; STRMAP(struct jsonrpc_request *) pending_requests;
struct log *log; struct logger *log;
struct log_book *log_book;
struct lightningd *ld; struct lightningd *ld;
const char *default_dir; const char *default_dir;
@ -349,7 +348,7 @@ struct io_plan *plugin_stdout_conn_init(struct io_conn *conn,
/** /**
* Needed for I/O logging for plugin messages. * Needed for I/O logging for plugin messages.
*/ */
struct log *plugin_get_log(struct plugin *plugin); struct logger *plugin_get_logger(struct plugin *plugin);
/** /**
* Tells the plugin system the directory for builtin plugins. * Tells the plugin system the directory for builtin plugins.

View File

@ -236,7 +236,7 @@ static void plugin_hook_call_next(struct plugin_hook_request *ph_req)
ph_req->hook->name, ph_req->plugin->shortname); ph_req->hook->name, ph_req->plugin->shortname);
req = jsonrpc_request_start(NULL, hook->name, ph_req->cmd_id, req = jsonrpc_request_start(NULL, hook->name, ph_req->cmd_id,
ph_req->plugin->non_numeric_ids, ph_req->plugin->non_numeric_ids,
plugin_get_log(ph_req->plugin), plugin_get_logger(ph_req->plugin),
NULL, NULL,
plugin_hook_callback, ph_req); plugin_hook_callback, ph_req);

View File

@ -696,7 +696,7 @@ static struct subd *new_subd(const tal_t *ctx,
const char *name, const char *name,
void *channel, void *channel,
const struct node_id *node_id, const struct node_id *node_id,
struct log *base_log, struct logger *base_log,
bool talks_to_peer, bool talks_to_peer,
const char *(*msgname)(int msgtype), const char *(*msgname)(int msgtype),
unsigned int (*msgcb)(struct subd *, unsigned int (*msgcb)(struct subd *,
@ -726,10 +726,10 @@ static struct subd *new_subd(const tal_t *ctx,
shortname = name; shortname = name;
if (base_log) { if (base_log) {
sd->log = new_log(sd, ld->log_book, node_id, sd->log = new_logger(sd, ld->log_book, node_id,
"%s-%s", shortname, log_prefix(base_log)); "%s-%s", shortname, log_prefix(base_log));
} else { } else {
sd->log = new_log(sd, ld->log_book, node_id, "%s", shortname); sd->log = new_logger(sd, ld->log_book, node_id, "%s", shortname);
} }
#if DEVELOPER #if DEVELOPER
@ -806,7 +806,7 @@ struct subd *new_channel_subd_(const tal_t *ctx,
const char *name, const char *name,
void *channel, void *channel,
const struct node_id *node_id, const struct node_id *node_id,
struct log *base_log, struct logger *base_log,
bool talks_to_peer, bool talks_to_peer,
const char *(*msgname)(int msgtype), const char *(*msgname)(int msgtype),
unsigned int (*msgcb)(struct subd *, const u8 *, unsigned int (*msgcb)(struct subd *, const u8 *,

View File

@ -39,7 +39,7 @@ struct subd {
bool rcvd_version; bool rcvd_version;
/* For logging */ /* For logging */
struct log *log; struct logger *log;
const struct node_id *node_id; const struct node_id *node_id;
/* Callback when non-reply message comes in (inside db transaction) */ /* Callback when non-reply message comes in (inside db transaction) */
@ -126,7 +126,7 @@ struct subd *new_channel_subd_(const tal_t *ctx,
const char *name, const char *name,
void *channel, void *channel,
const struct node_id *node_id, const struct node_id *node_id,
struct log *base_log, struct logger *base_log,
bool talks_to_peer, bool talks_to_peer,
const char *(*msgname)(int msgtype), const char *(*msgname)(int msgtype),
unsigned int (*msgcb)(struct subd *, const u8 *, unsigned int (*msgcb)(struct subd *, const u8 *,

View File

@ -130,7 +130,7 @@ void jsonrpc_stop_listening(struct jsonrpc *jsonrpc UNNEEDED)
struct htlc_in_map *load_channels_from_wallet(struct lightningd *ld UNNEEDED) struct htlc_in_map *load_channels_from_wallet(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "load_channels_from_wallet called!\n"); abort(); } { fprintf(stderr, "load_channels_from_wallet called!\n"); abort(); }
/* Generated stub for log_ */ /* Generated stub for log_ */
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, void log_(struct logger *logger UNNEEDED, enum log_level level UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, bool call_notifier UNNEEDED,
const char *fmt UNNEEDED, ...) const char *fmt UNNEEDED, ...)
@ -143,29 +143,29 @@ void log_backtrace_exit(void)
void log_backtrace_print(const char *fmt UNNEEDED, ...) void log_backtrace_print(const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "log_backtrace_print called!\n"); abort(); } { fprintf(stderr, "log_backtrace_print called!\n"); abort(); }
/* Generated stub for log_prefix */ /* Generated stub for log_prefix */
const char *log_prefix(const struct log *log UNNEEDED) const char *log_prefix(const struct logger *logger UNNEEDED)
{ fprintf(stderr, "log_prefix called!\n"); abort(); } { fprintf(stderr, "log_prefix called!\n"); abort(); }
/* Generated stub for log_print_level */ /* Generated stub for log_print_level */
enum log_level log_print_level(struct log *log UNNEEDED, const struct node_id *node_id UNNEEDED) enum log_level log_print_level(struct logger *log UNNEEDED, const struct node_id *node_id UNNEEDED)
{ fprintf(stderr, "log_print_level called!\n"); abort(); } { fprintf(stderr, "log_print_level called!\n"); abort(); }
/* Generated stub for log_status_msg */ /* Generated stub for log_status_msg */
bool log_status_msg(struct log *log UNNEEDED, bool log_status_msg(struct logger *log UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
const u8 *msg UNNEEDED) const u8 *msg UNNEEDED)
{ fprintf(stderr, "log_status_msg called!\n"); abort(); } { fprintf(stderr, "log_status_msg called!\n"); abort(); }
/* Generated stub for new_log */
struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED,
const struct node_id *default_node_id UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "new_log called!\n"); abort(); }
/* Generated stub for new_log_book */ /* Generated stub for new_log_book */
struct log_book *new_log_book(struct lightningd *ld UNNEEDED, size_t max_mem UNNEEDED) struct log_book *new_log_book(struct lightningd *ld UNNEEDED, size_t max_mem UNNEEDED)
{ fprintf(stderr, "new_log_book called!\n"); abort(); } { fprintf(stderr, "new_log_book called!\n"); abort(); }
/* Generated stub for new_logger */
struct logger *new_logger(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED,
const struct node_id *default_node_id UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "new_logger called!\n"); abort(); }
/* Generated stub for new_peer_fd_arr */ /* Generated stub for new_peer_fd_arr */
struct peer_fd *new_peer_fd_arr(const tal_t *ctx UNNEEDED, const int *fd UNNEEDED) struct peer_fd *new_peer_fd_arr(const tal_t *ctx UNNEEDED, const int *fd UNNEEDED)
{ fprintf(stderr, "new_peer_fd_arr called!\n"); abort(); } { fprintf(stderr, "new_peer_fd_arr called!\n"); abort(); }
/* Generated stub for new_topology */ /* Generated stub for new_topology */
struct chain_topology *new_topology(struct lightningd *ld UNNEEDED, struct log *log UNNEEDED) struct chain_topology *new_topology(struct lightningd *ld UNNEEDED, struct logger *log UNNEEDED)
{ fprintf(stderr, "new_topology called!\n"); abort(); } { fprintf(stderr, "new_topology called!\n"); abort(); }
/* Generated stub for onchaind_replay_channels */ /* Generated stub for onchaind_replay_channels */
void onchaind_replay_channels(struct lightningd *ld UNNEEDED) void onchaind_replay_channels(struct lightningd *ld UNNEEDED)
@ -240,7 +240,7 @@ bool wallet_sanity_check(struct wallet *w UNNEEDED)
{ fprintf(stderr, "wallet_sanity_check called!\n"); abort(); } { fprintf(stderr, "wallet_sanity_check called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */ /* AUTOGENERATED MOCKS END */
struct log *crashlog; struct logger *crashlog;
#undef main #undef main
int main(int argc UNUSED, char *argv[]) int main(int argc UNUSED, char *argv[])

View File

@ -13,11 +13,6 @@ struct channel *any_channel_by_scid(struct lightningd *ld UNNEEDED,
const struct short_channel_id *scid UNNEEDED, const struct short_channel_id *scid UNNEEDED,
bool privacy_leak_ok UNNEEDED) bool privacy_leak_ok UNNEEDED)
{ fprintf(stderr, "any_channel_by_scid called!\n"); abort(); } { fprintf(stderr, "any_channel_by_scid called!\n"); abort(); }
/* Generated stub for param_invstring */
struct command_result *param_invstring(struct command *cmd, const char *name,
const char * buffer, const jsmntok_t *tok,
const char **str)
{ fprintf(stderr, "param_invstring called!\n"); abort(); }
/* Generated stub for bip32_pubkey */ /* Generated stub for bip32_pubkey */
void bip32_pubkey(struct lightningd *ld UNNEEDED, struct pubkey *pubkey UNNEEDED, u32 index UNNEEDED) void bip32_pubkey(struct lightningd *ld UNNEEDED, struct pubkey *pubkey UNNEEDED, u32 index UNNEEDED)
{ fprintf(stderr, "bip32_pubkey called!\n"); abort(); } { fprintf(stderr, "bip32_pubkey called!\n"); abort(); }
@ -148,7 +143,7 @@ struct command_result *command_failed(struct command *cmd UNNEEDED,
struct command_result *command_its_complicated(const char *why UNNEEDED) struct command_result *command_its_complicated(const char *why UNNEEDED)
{ fprintf(stderr, "command_its_complicated called!\n"); abort(); } { fprintf(stderr, "command_its_complicated called!\n"); abort(); }
/* Generated stub for command_log */ /* Generated stub for command_log */
struct log *command_log(struct command *cmd UNNEEDED) struct logger *command_log(struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_log called!\n"); abort(); } { fprintf(stderr, "command_log called!\n"); abort(); }
/* Generated stub for command_param_failed */ /* Generated stub for command_param_failed */
struct command_result *command_param_failed(void) struct command_result *command_param_failed(void)
@ -470,7 +465,7 @@ void json_add_invstring(struct json_stream *result UNNEEDED, const char *invstri
{ fprintf(stderr, "json_add_invstring called!\n"); abort(); } { fprintf(stderr, "json_add_invstring called!\n"); abort(); }
/* Generated stub for json_add_log */ /* Generated stub for json_add_log */
void json_add_log(struct json_stream *result UNNEEDED, void json_add_log(struct json_stream *result UNNEEDED,
const struct log_book *lr UNNEEDED, const struct log_book *log_book UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
enum log_level minlevel UNNEEDED) enum log_level minlevel UNNEEDED)
{ fprintf(stderr, "json_add_log called!\n"); abort(); } { fprintf(stderr, "json_add_log called!\n"); abort(); }
@ -612,7 +607,7 @@ struct jsonrpc_request *jsonrpc_request_start_(
const tal_t *ctx UNNEEDED, const char *method UNNEEDED, const tal_t *ctx UNNEEDED, const char *method UNNEEDED,
const char *id_prefix TAKES UNNEEDED, const char *id_prefix TAKES UNNEEDED,
bool id_as_string UNNEEDED, bool id_as_string UNNEEDED,
struct log *log UNNEEDED, bool add_header UNNEEDED, struct logger *log UNNEEDED, bool add_header UNNEEDED,
void (*notify_cb)(const char *buffer UNNEEDED, void (*notify_cb)(const char *buffer UNNEEDED,
const jsmntok_t *idtok UNNEEDED, const jsmntok_t *idtok UNNEEDED,
const jsmntok_t *methodtok UNNEEDED, const jsmntok_t *methodtok UNNEEDED,
@ -627,7 +622,7 @@ void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED,
const char *why UNNEEDED) const char *why UNNEEDED)
{ fprintf(stderr, "kill_uncommitted_channel called!\n"); abort(); } { fprintf(stderr, "kill_uncommitted_channel called!\n"); abort(); }
/* Generated stub for log_ */ /* Generated stub for log_ */
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, void log_(struct logger *logger UNNEEDED, enum log_level level UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, bool call_notifier UNNEEDED,
const char *fmt UNNEEDED, ...) const char *fmt UNNEEDED, ...)
@ -715,6 +710,11 @@ struct command_result *param_escaped_string(struct command *cmd UNNEEDED,
const jsmntok_t *tok UNNEEDED, const jsmntok_t *tok UNNEEDED,
const char **str UNNEEDED) const char **str UNNEEDED)
{ fprintf(stderr, "param_escaped_string called!\n"); abort(); } { fprintf(stderr, "param_escaped_string called!\n"); abort(); }
/* Generated stub for param_invstring */
struct command_result *param_invstring(struct command *cmd UNNEEDED, const char *name UNNEEDED,
const char * buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
const char **str UNNEEDED)
{ fprintf(stderr, "param_invstring called!\n"); abort(); }
/* Generated stub for param_label */ /* Generated stub for param_label */
struct command_result *param_label(struct command *cmd UNNEEDED, const char *name UNNEEDED, struct command_result *param_label(struct command *cmd UNNEEDED, const char *name UNNEEDED,
const char * buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, const char * buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,

View File

@ -53,14 +53,14 @@ bool json_to_number(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
unsigned int *num UNNEEDED) unsigned int *num UNNEEDED)
{ fprintf(stderr, "json_to_number called!\n"); abort(); } { fprintf(stderr, "json_to_number called!\n"); abort(); }
/* Generated stub for log_ */ /* Generated stub for log_ */
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, void log_(struct logger *logger UNNEEDED, enum log_level level UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, bool call_notifier UNNEEDED,
const char *fmt UNNEEDED, ...) const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "log_ called!\n"); abort(); } { fprintf(stderr, "log_ called!\n"); abort(); }
/* Generated stub for log_io */ /* Generated stub for log_io */
void log_io(struct log *log UNNEEDED, enum log_level dir UNNEEDED, void log_io(struct logger *logger UNNEEDED, enum log_level dir UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
const char *comment UNNEEDED, const char *comment UNNEEDED,
const void *data UNNEEDED, size_t len UNNEEDED) const void *data UNNEEDED, size_t len UNNEEDED)
@ -71,11 +71,11 @@ const char *log_level_name(enum log_level level UNNEEDED)
/* Generated stub for mutual_close_feerate */ /* Generated stub for mutual_close_feerate */
u32 mutual_close_feerate(struct chain_topology *topo UNNEEDED) u32 mutual_close_feerate(struct chain_topology *topo UNNEEDED)
{ fprintf(stderr, "mutual_close_feerate called!\n"); abort(); } { fprintf(stderr, "mutual_close_feerate called!\n"); abort(); }
/* Generated stub for new_log */ /* Generated stub for new_logger */
struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, struct logger *new_logger(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED,
const struct node_id *default_node_id UNNEEDED, const struct node_id *default_node_id UNNEEDED,
const char *fmt UNNEEDED, ...) const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "new_log called!\n"); abort(); } { fprintf(stderr, "new_logger called!\n"); abort(); }
/* Generated stub for new_reltimer_ */ /* Generated stub for new_reltimer_ */
struct oneshot *new_reltimer_(struct timers *timers UNNEEDED, struct oneshot *new_reltimer_(struct timers *timers UNNEEDED,
const tal_t *ctx UNNEEDED, const tal_t *ctx UNNEEDED,

View File

@ -105,14 +105,14 @@ void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct log_book *lb; struct log_book *lb;
struct log *l; struct logger *l;
common_setup(argv[0]); common_setup(argv[0]);
lb = new_log_book(NULL, lb = new_log_book(NULL,
(sizeof(struct log_entry) + sizeof("test XXXXXX")) (sizeof(struct log_entry) + sizeof("test XXXXXX"))
*100); *100);
l = new_log(lb, lb, NULL, "test %s", "prefix"); l = new_logger(lb, lb, NULL, "test %s", "prefix");
assert(streq(log_prefix(l), "test prefix")); assert(streq(log_prefix(l), "test prefix"));

View File

@ -76,28 +76,28 @@ bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDE
bool fromwire_status_version(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, wirestring **version UNNEEDED) bool fromwire_status_version(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, wirestring **version UNNEEDED)
{ fprintf(stderr, "fromwire_status_version called!\n"); abort(); } { fprintf(stderr, "fromwire_status_version called!\n"); abort(); }
/* Generated stub for log_ */ /* Generated stub for log_ */
void log_(struct log *log UNNEEDED, enum log_level level UNNEEDED, void log_(struct logger *logger UNNEEDED, enum log_level level UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, bool call_notifier UNNEEDED,
const char *fmt UNNEEDED, ...) const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "log_ called!\n"); abort(); } { fprintf(stderr, "log_ called!\n"); abort(); }
/* Generated stub for log_prefix */ /* Generated stub for log_prefix */
const char *log_prefix(const struct log *log UNNEEDED) const char *log_prefix(const struct logger *logger UNNEEDED)
{ fprintf(stderr, "log_prefix called!\n"); abort(); } { fprintf(stderr, "log_prefix called!\n"); abort(); }
/* Generated stub for log_print_level */ /* Generated stub for log_print_level */
enum log_level log_print_level(struct log *log UNNEEDED, const struct node_id *node_id UNNEEDED) enum log_level log_print_level(struct logger *log UNNEEDED, const struct node_id *node_id UNNEEDED)
{ fprintf(stderr, "log_print_level called!\n"); abort(); } { fprintf(stderr, "log_print_level called!\n"); abort(); }
/* Generated stub for log_status_msg */ /* Generated stub for log_status_msg */
bool log_status_msg(struct log *log UNNEEDED, bool log_status_msg(struct logger *log UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
const u8 *msg UNNEEDED) const u8 *msg UNNEEDED)
{ fprintf(stderr, "log_status_msg called!\n"); abort(); } { fprintf(stderr, "log_status_msg called!\n"); abort(); }
/* Generated stub for new_log */ /* Generated stub for new_logger */
struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, struct logger *new_logger(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED,
const struct node_id *default_node_id UNNEEDED, const struct node_id *default_node_id UNNEEDED,
const char *fmt UNNEEDED, ...) const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "new_log called!\n"); abort(); } { fprintf(stderr, "new_logger called!\n"); abort(); }
/* Generated stub for new_peer_fd_arr */ /* Generated stub for new_peer_fd_arr */
struct peer_fd *new_peer_fd_arr(const tal_t *ctx UNNEEDED, const int *fd UNNEEDED) struct peer_fd *new_peer_fd_arr(const tal_t *ctx UNNEEDED, const int *fd UNNEEDED)
{ fprintf(stderr, "new_peer_fd_arr called!\n"); abort(); } { fprintf(stderr, "new_peer_fd_arr called!\n"); abort(); }

View File

@ -213,7 +213,7 @@ static bool txw_fire(struct txwatch *txw,
unsigned int depth) unsigned int depth)
{ {
enum watch_result r; enum watch_result r;
struct log *log; struct logger *log;
if (depth == txw->depth) if (depth == txw->depth)
return false; return false;

View File

@ -1,7 +1,7 @@
#include "config.h" #include "config.h"
#include <lightningd/log.h> #include <lightningd/log.h>
static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const struct node_id *node_id UNUSED, bool call_notifier UNUSED, const char *fmt UNUSED, ...) static void db_log_(struct logger *log UNUSED, enum log_level level UNUSED, const struct node_id *node_id UNUSED, bool call_notifier UNUSED, const char *fmt UNUSED, ...)
{ {
} }
#define log_ db_log_ #define log_ db_log_
@ -47,12 +47,15 @@ void get_channel_basepoints(struct lightningd *ld UNNEEDED,
struct pubkey *local_funding_pubkey UNNEEDED) struct pubkey *local_funding_pubkey UNNEEDED)
{ fprintf(stderr, "get_channel_basepoints called!\n"); abort(); } { fprintf(stderr, "get_channel_basepoints called!\n"); abort(); }
/* Generated stub for logv */ /* Generated stub for logv */
void logv(struct log *log UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED, void logv(struct logger *logger UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED) bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
{ fprintf(stderr, "logv called!\n"); abort(); } { fprintf(stderr, "logv called!\n"); abort(); }
/* Generated stub for psbt_fixup */ /* Generated stub for psbt_fixup */
const u8 *psbt_fixup(const tal_t *ctx UNNEEDED, const u8 *psbtblob UNNEEDED) const u8 *psbt_fixup(const tal_t *ctx UNNEEDED, const u8 *psbtblob UNNEEDED)
{ fprintf(stderr, "psbt_fixup called!\n"); abort(); } { fprintf(stderr, "psbt_fixup called!\n"); abort(); }
/* Generated stub for to_canonical_invstr */
const char *to_canonical_invstr(const tal_t *ctx UNNEEDED, const char *invstring UNNEEDED)
{ fprintf(stderr, "to_canonical_invstr called!\n"); abort(); }
/* Generated stub for towire_hsmd_get_channel_basepoints */ /* Generated stub for towire_hsmd_get_channel_basepoints */
u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED) u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
{ fprintf(stderr, "towire_hsmd_get_channel_basepoints called!\n"); abort(); } { fprintf(stderr, "towire_hsmd_get_channel_basepoints called!\n"); abort(); }
@ -65,9 +68,6 @@ u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED)
/* Generated stub for wire_sync_write */ /* Generated stub for wire_sync_write */
bool wire_sync_write(int fd UNNEEDED, const void *msg TAKES UNNEEDED) bool wire_sync_write(int fd UNNEEDED, const void *msg TAKES UNNEEDED)
{ fprintf(stderr, "wire_sync_write called!\n"); abort(); } { fprintf(stderr, "wire_sync_write called!\n"); abort(); }
/* Generated stub for strip_lightning_prefix */
const char *to_canonical_invstr(const tal_t *ctx, const char *invstring UNNEEDED)
{ fprintf(stderr, "strip_lightning_prefix called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */ /* AUTOGENERATED MOCKS END */
void plugin_hook_db_sync(struct db *db UNNEEDED) void plugin_hook_db_sync(struct db *db UNNEEDED)

View File

@ -5,7 +5,7 @@
#include <ccan/tal/str/str.h> #include <ccan/tal/str/str.h>
#include <db/common.h> #include <db/common.h>
static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const struct node_id *node_id UNUSED, bool call_notifier UNUSED, const char *fmt UNUSED, ...) static void db_log_(struct logger *log UNUSED, enum log_level level UNUSED, const struct node_id *node_id UNUSED, bool call_notifier UNUSED, const char *fmt UNUSED, ...)
{ {
} }
#define log_ db_log_ #define log_ db_log_
@ -38,9 +38,6 @@ static void test_error(struct lightningd *ld, bool fatal, const char *fmt, va_li
#include <stdio.h> #include <stdio.h>
/* AUTOGENERATED MOCKS START */ /* AUTOGENERATED MOCKS START */
/* Generated stub for strip_lightning_prefix */
const char *to_canonical_invstr(const tal_t *ctx, const char *invstring UNNEEDED)
{ fprintf(stderr, "strip_lightning_prefix called!\n"); abort(); }
/* Generated stub for bigsize_put */ /* Generated stub for bigsize_put */
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED) size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
{ fprintf(stderr, "bigsize_put called!\n"); abort(); } { fprintf(stderr, "bigsize_put called!\n"); abort(); }
@ -283,7 +280,7 @@ void json_add_hex_talarr(struct json_stream *result UNNEEDED,
{ fprintf(stderr, "json_add_hex_talarr called!\n"); abort(); } { fprintf(stderr, "json_add_hex_talarr called!\n"); abort(); }
/* Generated stub for json_add_log */ /* Generated stub for json_add_log */
void json_add_log(struct json_stream *result UNNEEDED, void json_add_log(struct json_stream *result UNNEEDED,
const struct log_book *lr UNNEEDED, const struct log_book *log_book UNNEEDED,
const struct node_id *node_id UNNEEDED, const struct node_id *node_id UNNEEDED,
enum log_level minlevel UNNEEDED) enum log_level minlevel UNNEEDED)
{ fprintf(stderr, "json_add_log called!\n"); abort(); } { fprintf(stderr, "json_add_log called!\n"); abort(); }
@ -424,7 +421,7 @@ void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED,
const char *why UNNEEDED) const char *why UNNEEDED)
{ fprintf(stderr, "kill_uncommitted_channel called!\n"); abort(); } { fprintf(stderr, "kill_uncommitted_channel called!\n"); abort(); }
/* Generated stub for logv */ /* Generated stub for logv */
void logv(struct log *log UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED, void logv(struct logger *logger UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED,
bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED) bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
{ fprintf(stderr, "logv called!\n"); abort(); } { fprintf(stderr, "logv called!\n"); abort(); }
/* Generated stub for new_channel_mvt_invoice_hin */ /* Generated stub for new_channel_mvt_invoice_hin */
@ -705,6 +702,9 @@ void subkey_from_hmac(const char *prefix UNNEEDED,
const struct secret *base UNNEEDED, const struct secret *base UNNEEDED,
struct secret *key UNNEEDED) struct secret *key UNNEEDED)
{ fprintf(stderr, "subkey_from_hmac called!\n"); abort(); } { fprintf(stderr, "subkey_from_hmac called!\n"); abort(); }
/* Generated stub for to_canonical_invstr */
const char *to_canonical_invstr(const tal_t *ctx UNNEEDED, const char *invstring UNNEEDED)
{ fprintf(stderr, "to_canonical_invstr called!\n"); abort(); }
/* Generated stub for topology_add_sync_waiter_ */ /* Generated stub for topology_add_sync_waiter_ */
void topology_add_sync_waiter_(const tal_t *ctx UNNEEDED, void topology_add_sync_waiter_(const tal_t *ctx UNNEEDED,
struct chain_topology *topo UNNEEDED, struct chain_topology *topo UNNEEDED,
@ -923,7 +923,7 @@ bool fromwire_hsmd_get_channel_basepoints_reply(const void *p UNNEEDED,
#define transaction_wrap(db, ...) \ #define transaction_wrap(db, ...) \
(db_begin_transaction(db), __VA_ARGS__, db_commit_transaction(db), wallet_err == NULL) (db_begin_transaction(db), __VA_ARGS__, db_commit_transaction(db), wallet_err == NULL)
struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, const struct node_id *default_node_id UNNEEDED, const char *fmt UNNEEDED, ...) struct logger *new_logger(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED, const struct node_id *default_node_id UNNEEDED, const char *fmt UNNEEDED, ...)
{ {
return NULL; return NULL;
} }

View File

@ -106,7 +106,7 @@ struct wallet *wallet_new(struct lightningd *ld, struct timers *timers)
{ {
struct wallet *wallet = tal(ld, struct wallet); struct wallet *wallet = tal(ld, struct wallet);
wallet->ld = ld; wallet->ld = ld;
wallet->log = new_log(wallet, ld->log_book, NULL, "wallet"); wallet->log = new_logger(wallet, ld->log_book, NULL, "wallet");
wallet->keyscan_gap = 50; wallet->keyscan_gap = 50;
list_head_init(&wallet->unstored_payments); list_head_init(&wallet->unstored_payments);
wallet->db = db_setup(wallet, ld, ld->bip32_base); wallet->db = db_setup(wallet, ld, ld->bip32_base);

View File

@ -27,7 +27,7 @@ enum state_change;
struct wallet { struct wallet {
struct lightningd *ld; struct lightningd *ld;
struct db *db; struct db *db;
struct log *log; struct logger *log;
struct invoices *invoices; struct invoices *invoices;
struct list_head unstored_payments; struct list_head unstored_payments;
u64 max_channel_dbid; u64 max_channel_dbid;