MCPcopy Create free account
hub / github.com/ElementsProject/lightning / logv

Function logv

lightningd/log.c:662–704  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662void logv(struct logger *log, enum log_level level,
663 const struct node_id *node_id,
664 bool call_notifier,
665 const char *fmt, va_list ap)
666{
667 int save_errno = errno;
668 struct log_hdr l;
669 size_t log_len;
670 char *logmsg;
671 const char *capped;
672
673 /* This is WARN_UNUSED_RESULT, because everyone should somehow deal
674 * with OOM, even though nobody does. */
675 if (vasprintf(&logmsg, fmt, ap) == -1)
676 abort();
677
678 log_len = strlen(logmsg);
679
680 /* Sanitize any non-printable characters, and replace with '?' */
681 for (size_t i=0; i<log_len; i++)
682 if (logmsg[i] < ' ' || logmsg[i] >= 0x7f)
683 logmsg[i] = '?';
684
685 init_log_hdr(log, &l, level, node_id, log_len, 0);
686 maybe_print(log, &l, logmsg, NULL);
687 maybe_notify_log(log, &l, logmsg);
688
689 /* cap_header() hands back a tal allocation when it truncates, so
690 * don't lose the malloc'd pointer: free() on tal memory corrupts
691 * the heap. Entries above sizeof(ringbuf)/64 hit this. */
692 capped = cap_header(tmpctx, &l, logmsg);
693 add_entry(log->log_book, &l, capped, NULL);
694
695 if (call_notifier)
696 notify_warning(log->log_book->ld,
697 l.level,
698 l.time,
699 l.prefix->prefix,
700 capped);
701 free(logmsg);
702
703 errno = save_errno;
704}
705
706void log_io(struct logger *log, enum log_level dir,
707 const struct node_id *node_id,

Callers 4

log_Function · 0.70
log_backtrace_printFunction · 0.70
fatal_vfmtFunction · 0.70
memleak_logFunction · 0.70

Calls 7

abortFunction · 0.85
init_log_hdrFunction · 0.85
maybe_notify_logFunction · 0.85
cap_headerFunction · 0.85
add_entryFunction · 0.85
maybe_printFunction · 0.70
notify_warningFunction · 0.70

Tested by

no test coverage detected