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

Function logv

lightningd/log.c:653–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653void logv(struct logger *log, enum log_level level,
654 const struct node_id *node_id,
655 bool call_notifier,
656 const char *fmt, va_list ap)
657{
658 int save_errno = errno;
659 struct log_hdr l;
660 size_t log_len;
661 char *logmsg;
662
663 /* This is WARN_UNUSED_RESULT, because everyone should somehow deal
664 * with OOM, even though nobody does. */
665 if (vasprintf(&logmsg, fmt, ap) == -1)
666 abort();
667
668 log_len = strlen(logmsg);
669
670 /* Sanitize any non-printable characters, and replace with '?' */
671 for (size_t i=0; i<log_len; i++)
672 if (logmsg[i] < ' ' || logmsg[i] >= 0x7f)
673 logmsg[i] = '?';
674
675 init_log_hdr(log, &l, level, node_id, log_len, 0);
676 maybe_print(log, &l, logmsg, NULL);
677 maybe_notify_log(log, &l, logmsg);
678
679 logmsg = cap_header(tmpctx, &l, logmsg);
680 add_entry(log->log_book, &l, logmsg, NULL);
681
682 if (call_notifier)
683 notify_warning(log->log_book->ld,
684 l.level,
685 l.time,
686 l.prefix->prefix,
687 logmsg);
688 free(logmsg);
689
690 errno = save_errno;
691}
692
693void log_io(struct logger *log, enum log_level dir,
694 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