| 486 | } |
| 487 | |
| 488 | void |
| 489 | xo_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 |
no test coverage detected