| 372 | } |
| 373 | |
| 374 | static struct log_entry *new_log_entry(struct log *log, enum log_level level, |
| 375 | const struct node_id *node_id) |
| 376 | { |
| 377 | struct log_entry *l; |
| 378 | |
| 379 | if (log->lr->num_entries == tal_count(log->lr->log)) |
| 380 | tal_resize(&log->lr->log, tal_count(log->lr->log) * 2); |
| 381 | |
| 382 | l = &log->lr->log[log->lr->num_entries]; |
| 383 | l->time = time_now(); |
| 384 | l->level = level; |
| 385 | l->skipped = 0; |
| 386 | l->prefix = log_prefix_get(log->prefix); |
| 387 | l->io = NULL; |
| 388 | if (!node_id) |
| 389 | node_id = log->default_node_id; |
| 390 | if (node_id) { |
| 391 | l->nc = node_id_map_get(log->lr->cache, node_id); |
| 392 | if (!l->nc) { |
| 393 | l->nc = tal(log->lr->cache, struct node_id_cache); |
| 394 | l->nc->count = 0; |
| 395 | l->nc->node_id = *node_id; |
| 396 | node_id_map_add(log->lr->cache, l->nc); |
| 397 | tal_add_destructor2(l->nc, destroy_node_id_cache, |
| 398 | log->lr); |
| 399 | } |
| 400 | l->nc->count++; |
| 401 | } else |
| 402 | l->nc = NULL; |
| 403 | |
| 404 | return l; |
| 405 | } |
| 406 | |
| 407 | static void maybe_print(struct log *log, const struct log_entry *l) |
| 408 | { |
no test coverage detected