| 270 | } |
| 271 | |
| 272 | struct log_book *new_log_book(struct lightningd *ld, size_t max_mem) |
| 273 | { |
| 274 | struct log_book *lr = tal_linkable(tal(NULL, struct log_book)); |
| 275 | |
| 276 | /* Give a reasonable size for memory limit! */ |
| 277 | assert(max_mem > sizeof(struct log) * 2); |
| 278 | lr->mem_used = 0; |
| 279 | lr->num_entries = 0; |
| 280 | lr->max_mem = max_mem; |
| 281 | lr->outfiles = NULL; |
| 282 | lr->default_print_level = NULL; |
| 283 | /* We have to allocate this, since we tal_free it on resetting */ |
| 284 | lr->prefix = tal_strdup(lr, ""); |
| 285 | list_head_init(&lr->print_filters); |
| 286 | lr->init_time = time_now(); |
| 287 | lr->ld = ld; |
| 288 | lr->cache = tal(lr, struct node_id_map); |
| 289 | node_id_map_init(lr->cache); |
| 290 | lr->log = tal_arr(lr, struct log_entry, 128); |
| 291 | lr->print_timestamps = true; |
| 292 | tal_add_destructor(lr, destroy_log_book); |
| 293 | |
| 294 | return lr; |
| 295 | } |
| 296 | |
| 297 | static enum log_level filter_level(struct log_book *lr, |
| 298 | const struct log_prefix *lp, |
no test coverage detected