log: keep dstate pointer.

We need its secpctx pointer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-07-01 11:19:28 +09:30
parent 08a910b06e
commit a35055c699
2 changed files with 7 additions and 3 deletions

View File

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

View File

@ -6,6 +6,7 @@
#include <stdarg.h>
struct timerel;
struct lightningd_state;
enum log_level {
/* Logging all IO. */
@ -21,7 +22,7 @@ enum log_level {
};
/* We have a single record. */
struct log_record *new_log_record(const tal_t *ctx,
struct log_record *new_log_record(struct lightningd_state *dstate,
size_t max_mem,
enum log_level printlevel);