MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_vsyslog

Function xo_vsyslog

tools/libxo/libxo/xo_syslog.c:488–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488void
489xo_vsyslog (int pri, const char *name, const char *fmt, va_list vap)
490{
491 int saved_errno = errno;
492 char tbuf[2048];
493 char *tp = NULL, *ep = NULL;
494 unsigned start_of_msg = 0;
495 char *v0_hdr = NULL;
496 xo_buffer_t xb;
497 static pid_t my_pid;
498 unsigned log_offset;
499
500 if (my_pid == 0)
501 my_pid = xo_unit_test ? 222 : getpid();
502
503 /* Check for invalid bits */
504 if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) {
505 xo_syslog(LOG_ERR | LOG_CONS | LOG_PERROR | LOG_PID,
506 "syslog-unknown-priority",
507 "syslog: unknown facility/priority: %#x", pri);
508 pri &= LOG_PRIMASK|LOG_FACMASK;
509 }
510
511 THREAD_LOCK();
512
513 /* Check priority against setlogmask values. */
514 if (!(LOG_MASK(LOG_PRI(pri)) & xo_logmask)) {
515 THREAD_UNLOCK();
516 return;
517 }
518
519 /* Set default facility if none specified. */
520 if ((pri & LOG_FACMASK) == 0)
521 pri |= xo_logfacility;
522
523 /* Create the primary stdio hook */
524 xb.xb_bufp = tbuf;
525 xb.xb_curp = tbuf;
526 xb.xb_size = sizeof(tbuf);
527
528 xo_handle_t *xop = xo_create(XO_STYLE_SDPARAMS, 0);
529 if (xop == NULL) {
530 THREAD_UNLOCK();
531 return;
532 }
533
534#ifdef HAVE_GETPROGNAME
535 if (xo_logtag == NULL)
536 xo_logtag = getprogname();
537#endif /* HAVE_GETPROGNAME */
538
539 xo_set_writer(xop, &xb, xo_syslog_handle_write, xo_syslog_handle_close,
540 xo_syslog_handle_flush);
541
542 /* Build the message; start by getting the time */
543 struct tm tm;
544 struct timeval tv;
545

Callers 1

xo_syslogFunction · 0.85

Calls 15

xo_syslogFunction · 0.85
xo_createFunction · 0.85
getprognameFunction · 0.85
xo_set_writerFunction · 0.85
xo_snprintfFunction · 0.85
xo_buf_leftFunction · 0.85
sysctlbynameFunction · 0.85
xo_emit_hvFunction · 0.85
xo_flush_hFunction · 0.85
xo_set_styleFunction · 0.85
xo_set_flagsFunction · 0.85

Tested by

no test coverage detected