mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
log: rename struct log_record to struct log_book.
I think "log entry" when I see "log record", so this name is better. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -966,7 +966,7 @@ static void db_load_peers(struct lightningd_state *dstate)
|
|||||||
sqlite3_column_str(stmt, 1));
|
sqlite3_column_str(stmt, 1));
|
||||||
pubkey_from_sql(stmt, 0, &id);
|
pubkey_from_sql(stmt, 0, &id);
|
||||||
idstr = pubkey_to_hexstr(dstate, &id);
|
idstr = pubkey_to_hexstr(dstate, &id);
|
||||||
l = new_log(dstate, dstate->log_record, "%s:", idstr);
|
l = new_log(dstate, dstate->log_book, "%s:", idstr);
|
||||||
tal_free(idstr);
|
tal_free(idstr);
|
||||||
peer = new_peer(dstate, l, state, sqlite3_column_int(stmt, 2));
|
peer = new_peer(dstate, l, state, sqlite3_column_int(stmt, 2));
|
||||||
peer->htlc_id_counter = 0;
|
peer->htlc_id_counter = 0;
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ void setup_irc_connection(struct lightningd_state *dstate)
|
|||||||
state->dstate = dstate;
|
state->dstate = dstate;
|
||||||
state->server = "irc.lfnet.org";
|
state->server = "irc.lfnet.org";
|
||||||
state->reconnect_timeout = time_from_sec(15);
|
state->reconnect_timeout = time_from_sec(15);
|
||||||
state->log = new_log(state, state->dstate->log_record, "%s:irc",
|
state->log = new_log(state, state->dstate->log_book, "%s:irc",
|
||||||
log_prefix(state->dstate->base_log));
|
log_prefix(state->dstate->base_log));
|
||||||
|
|
||||||
/* Truncate nick at 13 bytes, would be imposed by freenode anyway */
|
/* Truncate nick at 13 bytes, would be imposed by freenode anyway */
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ static void json_getlog(struct command *cmd,
|
|||||||
const char *buffer, const jsmntok_t *params)
|
const char *buffer, const jsmntok_t *params)
|
||||||
{
|
{
|
||||||
struct log_info info;
|
struct log_info info;
|
||||||
struct log_record *lr = cmd->dstate->log_record;
|
struct log_book *lr = cmd->dstate->log_book;
|
||||||
jsmntok_t *level;
|
jsmntok_t *level;
|
||||||
|
|
||||||
json_get_params(buffer, params, "?level", &level, NULL);
|
json_get_params(buffer, params, "?level", &level, NULL);
|
||||||
@@ -576,7 +576,7 @@ static struct io_plan *jcon_connected(struct io_conn *conn,
|
|||||||
jcon->buffer = tal_arr(jcon, char, 64);
|
jcon->buffer = tal_arr(jcon, char, 64);
|
||||||
jcon->stop = false;
|
jcon->stop = false;
|
||||||
jcon->current = NULL;
|
jcon->current = NULL;
|
||||||
jcon->log = new_log(jcon, dstate->log_record, "%sjcon fd %i:",
|
jcon->log = new_log(jcon, dstate->log_book, "%sjcon fd %i:",
|
||||||
log_prefix(dstate->base_log), io_conn_fd(conn));
|
log_prefix(dstate->base_log), io_conn_fd(conn));
|
||||||
list_head_init(&jcon->output);
|
list_head_init(&jcon->output);
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ static struct lightningd_state *lightningd_state(void)
|
|||||||
{
|
{
|
||||||
struct lightningd_state *dstate = tal(NULL, struct lightningd_state);
|
struct lightningd_state *dstate = tal(NULL, struct lightningd_state);
|
||||||
|
|
||||||
dstate->log_record = new_log_record(dstate, 20*1024*1024, LOG_INFORM);
|
dstate->log_book = new_log_book(dstate, 20*1024*1024, LOG_INFORM);
|
||||||
dstate->base_log = new_log(dstate, dstate->log_record,
|
dstate->base_log = new_log(dstate, dstate->log_book,
|
||||||
"lightningd(%u):", (int)getpid());
|
"lightningd(%u):", (int)getpid());
|
||||||
|
|
||||||
list_head_init(&dstate->peers);
|
list_head_init(&dstate->peers);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ struct config {
|
|||||||
/* Here's where the global variables hide! */
|
/* Here's where the global variables hide! */
|
||||||
struct lightningd_state {
|
struct lightningd_state {
|
||||||
/* Where all our logging goes. */
|
/* Where all our logging goes. */
|
||||||
struct log_record *log_record;
|
struct log_book *log_book;
|
||||||
struct log *base_log;
|
struct log *base_log;
|
||||||
FILE *logf;
|
FILE *logf;
|
||||||
|
|
||||||
|
|||||||
26
daemon/log.c
26
daemon/log.c
@@ -26,7 +26,7 @@ struct log_entry {
|
|||||||
char *log;
|
char *log;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct log_record {
|
struct log_book {
|
||||||
size_t mem_used;
|
size_t mem_used;
|
||||||
size_t max_mem;
|
size_t max_mem;
|
||||||
void (*print)(const char *prefix,
|
void (*print)(const char *prefix,
|
||||||
@@ -41,7 +41,7 @@ struct log_record {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct log {
|
struct log {
|
||||||
struct log_record *lr;
|
struct log_book *lr;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ static size_t log_bufsize(const struct log_entry *e)
|
|||||||
return strlen(e->log) + 1;
|
return strlen(e->log) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t prune_log(struct log_record *log)
|
static size_t prune_log(struct log_book *log)
|
||||||
{
|
{
|
||||||
struct log_entry *i, *next, *tail;
|
struct log_entry *i, *next, *tail;
|
||||||
size_t skipped = 0, deleted = 0;
|
size_t skipped = 0, deleted = 0;
|
||||||
@@ -92,11 +92,11 @@ static size_t prune_log(struct log_record *log)
|
|||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct log_record *new_log_record(const tal_t *ctx,
|
struct log_book *new_log_book(const tal_t *ctx,
|
||||||
size_t max_mem,
|
size_t max_mem,
|
||||||
enum log_level printlevel)
|
enum log_level printlevel)
|
||||||
{
|
{
|
||||||
struct log_record *lr = tal(ctx, struct log_record);
|
struct log_book *lr = tal(ctx, 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 log) * 2);
|
||||||
@@ -112,7 +112,7 @@ struct log_record *new_log_record(const tal_t *ctx,
|
|||||||
|
|
||||||
/* With different entry points */
|
/* With different entry points */
|
||||||
struct log *PRINTF_FMT(3,4)
|
struct log *PRINTF_FMT(3,4)
|
||||||
new_log(const tal_t *ctx, struct log_record *record, const char *fmt, ...)
|
new_log(const tal_t *ctx, struct log_book *record, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct log *log = tal(ctx, struct log);
|
struct log *log = tal(ctx, struct log);
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -126,7 +126,7 @@ new_log(const tal_t *ctx, struct log_record *record, const char *fmt, ...)
|
|||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_log_level(struct log_record *lr, enum log_level level)
|
void set_log_level(struct log_book *lr, enum log_level level)
|
||||||
{
|
{
|
||||||
lr->print_level = level;
|
lr->print_level = level;
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ void set_log_prefix(struct log *log, const char *prefix)
|
|||||||
log->prefix = tal_strdup(log->lr, prefix);
|
log->prefix = tal_strdup(log->lr, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_log_outfn_(struct log_record *lr,
|
void set_log_outfn_(struct log_book *lr,
|
||||||
void (*print)(const char *prefix,
|
void (*print)(const char *prefix,
|
||||||
enum log_level level,
|
enum log_level level,
|
||||||
bool continued,
|
bool continued,
|
||||||
@@ -153,17 +153,17 @@ const char *log_prefix(const struct log *log)
|
|||||||
return log->prefix;
|
return log->prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t log_max_mem(const struct log_record *lr)
|
size_t log_max_mem(const struct log_book *lr)
|
||||||
{
|
{
|
||||||
return lr->max_mem;
|
return lr->max_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t log_used(const struct log_record *lr)
|
size_t log_used(const struct log_book *lr)
|
||||||
{
|
{
|
||||||
return lr->mem_used;
|
return lr->mem_used;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct timeabs *log_init_time(const struct log_record *lr)
|
const struct timeabs *log_init_time(const struct log_book *lr)
|
||||||
{
|
{
|
||||||
return &lr->init_time;
|
return &lr->init_time;
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ void log_blob_(struct log *log, int level, const char *fmt,
|
|||||||
tal_free(hex);
|
tal_free(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_each_line_(const struct log_record *lr,
|
void log_each_line_(const struct log_book *lr,
|
||||||
void (*func)(unsigned int skipped,
|
void (*func)(unsigned int skipped,
|
||||||
struct timerel time,
|
struct timerel time,
|
||||||
enum log_level level,
|
enum log_level level,
|
||||||
@@ -494,7 +494,7 @@ void crashlog_activate(struct log *log)
|
|||||||
sigaction(SIGBUS, &sa, NULL);
|
sigaction(SIGBUS, &sa, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_dump_to_file(int fd, const struct log_record *lr)
|
void log_dump_to_file(int fd, const struct log_book *lr)
|
||||||
{
|
{
|
||||||
const struct log_entry *i;
|
const struct log_entry *i;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
|||||||
20
daemon/log.h
20
daemon/log.h
@@ -22,14 +22,14 @@ enum log_level {
|
|||||||
LOG_BROKEN
|
LOG_BROKEN
|
||||||
};
|
};
|
||||||
|
|
||||||
/* We have a single record. */
|
/* We can have a single log book, with multiple logs in it. */
|
||||||
struct log_record *new_log_record(const tal_t *ctx,
|
struct log_book *new_log_book(const tal_t *ctx,
|
||||||
size_t max_mem,
|
size_t max_mem,
|
||||||
enum log_level printlevel);
|
enum log_level printlevel);
|
||||||
|
|
||||||
/* With different entry points */
|
/* With different entry points */
|
||||||
struct log *PRINTF_FMT(3,4)
|
struct log *PRINTF_FMT(3,4)
|
||||||
new_log(const tal_t *ctx, struct log_record *record, const char *fmt, ...);
|
new_log(const tal_t *ctx, struct log_book *record, const char *fmt, ...);
|
||||||
|
|
||||||
#define log_debug(log, ...) log_((log), LOG_DBG, __VA_ARGS__)
|
#define log_debug(log, ...) log_((log), LOG_DBG, __VA_ARGS__)
|
||||||
#define log_info(log, ...) log_((log), LOG_INFORM, __VA_ARGS__)
|
#define log_info(log, ...) log_((log), LOG_INFORM, __VA_ARGS__)
|
||||||
@@ -83,7 +83,7 @@ void PRINTF_FMT(4,5) log_struct_(struct log *log, int level,
|
|||||||
const char *structname,
|
const char *structname,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
|
|
||||||
void set_log_level(struct log_record *lr, enum log_level level);
|
void set_log_level(struct log_book *lr, enum log_level level);
|
||||||
void set_log_prefix(struct log *log, const char *prefix);
|
void set_log_prefix(struct log *log, const char *prefix);
|
||||||
const char *log_prefix(const struct log *log);
|
const char *log_prefix(const struct log *log);
|
||||||
#define set_log_outfn(lr, print, arg) \
|
#define set_log_outfn(lr, print, arg) \
|
||||||
@@ -94,16 +94,16 @@ const char *log_prefix(const struct log *log);
|
|||||||
bool, \
|
bool, \
|
||||||
const char *), (arg))
|
const char *), (arg))
|
||||||
|
|
||||||
void set_log_outfn_(struct log_record *lr,
|
void set_log_outfn_(struct log_book *lr,
|
||||||
void (*print)(const char *prefix,
|
void (*print)(const char *prefix,
|
||||||
enum log_level level,
|
enum log_level level,
|
||||||
bool continued,
|
bool continued,
|
||||||
const char *str, void *arg),
|
const char *str, void *arg),
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
size_t log_max_mem(const struct log_record *lr);
|
size_t log_max_mem(const struct log_book *lr);
|
||||||
size_t log_used(const struct log_record *lr);
|
size_t log_used(const struct log_book *lr);
|
||||||
const struct timeabs *log_init_time(const struct log_record *lr);
|
const struct timeabs *log_init_time(const struct log_book *lr);
|
||||||
|
|
||||||
#define log_each_line(lr, func, arg) \
|
#define log_each_line(lr, func, arg) \
|
||||||
log_each_line_((lr), \
|
log_each_line_((lr), \
|
||||||
@@ -114,7 +114,7 @@ const struct timeabs *log_init_time(const struct log_record *lr);
|
|||||||
const char *, \
|
const char *, \
|
||||||
const char *), (arg))
|
const char *), (arg))
|
||||||
|
|
||||||
void log_each_line_(const struct log_record *lr,
|
void log_each_line_(const struct log_book *lr,
|
||||||
void (*func)(unsigned int skipped,
|
void (*func)(unsigned int skipped,
|
||||||
struct timerel time,
|
struct timerel time,
|
||||||
enum log_level level,
|
enum log_level level,
|
||||||
@@ -124,7 +124,7 @@ void log_each_line_(const struct log_record *lr,
|
|||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
|
|
||||||
void log_dump_to_file(int fd, const struct log_record *lr);
|
void log_dump_to_file(int fd, const struct log_book *lr);
|
||||||
void opt_register_logging(struct log *log);
|
void opt_register_logging(struct log *log);
|
||||||
void crashlog_activate(struct log *log);
|
void crashlog_activate(struct log *log);
|
||||||
|
|
||||||
|
|||||||
@@ -2969,7 +2969,7 @@ static struct io_plan *peer_connected_out(struct io_conn *conn,
|
|||||||
struct log *l;
|
struct log *l;
|
||||||
struct netaddr addr;
|
struct netaddr addr;
|
||||||
|
|
||||||
l = new_log(conn, dstate->log_record, "OUT-%s:%s:",
|
l = new_log(conn, dstate->log_book, "OUT-%s:%s:",
|
||||||
connect->name, connect->port);
|
connect->name, connect->port);
|
||||||
|
|
||||||
if (!netaddr_from_fd(io_conn_fd(conn), SOCK_STREAM, IPPROTO_TCP, &addr)) {
|
if (!netaddr_from_fd(io_conn_fd(conn), SOCK_STREAM, IPPROTO_TCP, &addr)) {
|
||||||
@@ -3029,7 +3029,7 @@ static struct io_plan *peer_connected_in(struct io_conn *conn,
|
|||||||
if (!netaddr_from_fd(io_conn_fd(conn), SOCK_STREAM, IPPROTO_TCP, &addr))
|
if (!netaddr_from_fd(io_conn_fd(conn), SOCK_STREAM, IPPROTO_TCP, &addr))
|
||||||
return false;
|
return false;
|
||||||
name = netaddr_name(conn, &addr);
|
name = netaddr_name(conn, &addr);
|
||||||
l = new_log(conn, dstate->log_record, "IN-%s:", name);
|
l = new_log(conn, dstate->log_book, "IN-%s:", name);
|
||||||
|
|
||||||
log_debug(l, "Connected in");
|
log_debug(l, "Connected in");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user