|
@ -3,6 +3,7 @@ |
|
|
#include "bitcoin/tx.h" |
|
|
#include "bitcoin/tx.h" |
|
|
#include "controlled_time.h" |
|
|
#include "controlled_time.h" |
|
|
#include "htlc.h" |
|
|
#include "htlc.h" |
|
|
|
|
|
#include "lightningd.h" |
|
|
#include "log.h" |
|
|
#include "log.h" |
|
|
#include "peer.h" |
|
|
#include "peer.h" |
|
|
#include "protobuf_convert.h" |
|
|
#include "protobuf_convert.h" |
|
@ -36,6 +37,7 @@ struct log_entry { |
|
|
struct log_record { |
|
|
struct log_record { |
|
|
size_t mem_used; |
|
|
size_t mem_used; |
|
|
size_t max_mem; |
|
|
size_t max_mem; |
|
|
|
|
|
struct lightningd_state *dstate; |
|
|
void (*print)(const char *prefix, |
|
|
void (*print)(const char *prefix, |
|
|
enum log_level level, |
|
|
enum log_level level, |
|
|
bool continued, |
|
|
bool continued, |
|
@ -99,16 +101,17 @@ 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_record *new_log_record(struct lightningd_state *dstate, |
|
|
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_record *lr = tal(dstate, struct log_record); |
|
|
|
|
|
|
|
|
/* 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); |
|
|
lr->mem_used = 0; |
|
|
lr->mem_used = 0; |
|
|
lr->max_mem = max_mem; |
|
|
lr->max_mem = max_mem; |
|
|
|
|
|
lr->dstate = dstate; |
|
|
lr->print = log_default_print; |
|
|
lr->print = log_default_print; |
|
|
lr->print_level = printlevel; |
|
|
lr->print_level = printlevel; |
|
|
lr->init_time = time_now(); |
|
|
lr->init_time = time_now(); |
|
|