4 * Issue syslog messages via the kernel printk queue.
14 /* Maximum size for a kernel message */
18 #define LOGDEV "/dev/kmsg"
20 /* Max length of ID string */
24 static char id[MAXID+1];
26 void openlog(const char *ident, int option, int facility)
30 (void)option; (void)facility; /* Unused */
32 if ( __syslog_fd == -1 ) {
33 __syslog_fd = fd = open(LOGDEV, O_WRONLY);
36 fcntl(fd, F_SETFD, (long)FD_CLOEXEC);
39 strncpy(id, ident?ident:"", MAXID);
40 id[MAXID] = '\0'; /* Make sure it's null-terminated */
43 void vsyslog(int prio, const char *format, va_list ap)
49 if ( __syslog_fd == -1 )
54 fd = 2; /* Failed to open log, write to stderr */
57 buf[1] = LOG_PRI(prio)+'0';
62 len += sprintf(buf+3, "%s: ", id);
64 rv = vsnprintf(buf+len, BUFLEN-len, format, ap);
67 if ( len > BUFLEN-1 ) len = BUFLEN-1;
70 write(fd, buf, len+1);
73 void syslog(int prio, const char *format, ...)
78 vsyslog(prio, format, ap);