- fprintf(log_f, "<%d>%s ", priority, timebuf);
- if (log_ident) fprintf(log_f, "%s", log_ident);
- if (log_opt & LOG_PID) fprintf(log_f, "[%d]", getpid());
- if (log_ident) fprintf(log_f, ": ");
+ pid = (log_opt & LOG_PID) ? getpid() : 0;
+ l = snprintf(buf, sizeof buf, "<%d>%s %s%s%.0d%s: ",
+ priority, timebuf,
+ log_ident ? log_ident : "",
+ "["+!pid, pid, "]"+!pid);
+ l2 = vsnprintf(buf+l, sizeof buf - l, message, ap);
+ if (l2 >= 0) {
+ l += l2;
+ if (buf[l-1] != '\n') buf[l++] = '\n';
+ sendto(log_fd, buf, l, 0, (void *)&log_addr, 11);
+ }