chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] support log-priority levels in udev.conf
[elogind.git]
/
klibc
/
klibc
/
syslog.c
diff --git
a/klibc/klibc/syslog.c
b/klibc/klibc/syslog.c
index e9d84d9ddc8f1cf5bab1d2a28ccf5e7e8e4dbf29..0cd296ab8580753e89e19c8e754c178f3cfad70a 100644
(file)
--- a/
klibc/klibc/syslog.c
+++ b/
klibc/klibc/syslog.c
@@
-18,10
+18,11
@@
#define LOGDEV "/dev/kmsg"
/* Max length of ID string */
#define LOGDEV "/dev/kmsg"
/* Max length of ID string */
-#define MAXID 31 /* MAXID+
6
must be < BUFLEN */
+#define MAXID 31 /* MAXID+
5
must be < BUFLEN */
int __syslog_fd = -1;
static char id[MAXID+1];
int __syslog_fd = -1;
static char id[MAXID+1];
+static int syslog_flags = 0;
void openlog(const char *ident, int option, int facility)
{
void openlog(const char *ident, int option, int facility)
{
@@
-36,8
+37,9
@@
void openlog(const char *ident, int option, int facility)
fcntl(fd, F_SETFD, (long)FD_CLOEXEC);
}
fcntl(fd, F_SETFD, (long)FD_CLOEXEC);
}
+ syslog_flags = option;
+
strncpy(id, ident?ident:"", MAXID);
strncpy(id, ident?ident:"", MAXID);
- id[MAXID] = '\0'; /* Make sure it's null-terminated */
}
void vsyslog(int prio, const char *format, va_list ap)
}
void vsyslog(int prio, const char *format, va_list ap)
@@
-54,7
+56,9
@@
void vsyslog(int prio, const char *format, va_list ap)
buf[2] = '>';
len = 3;
buf[2] = '>';
len = 3;
- if ( *id )
+ if ( syslog_flags & LOG_PID )
+ len += sprintf(buf+3, "%s[%u]: ", id, getpid());
+ else if ( *id )
len += sprintf(buf+3, "%s: ", id);
len += vsnprintf(buf+len, BUFLEN-len, format, ap);
len += sprintf(buf+3, "%s: ", id);
len += vsnprintf(buf+len, BUFLEN-len, format, ap);
@@
-68,6
+72,9
@@
void vsyslog(int prio, const char *format, va_list ap)
fd = 2; /* Failed to open log, write to stderr */
write(fd, buf, len);
fd = 2; /* Failed to open log, write to stderr */
write(fd, buf, len);
+
+ if ( syslog_flags & LOG_PERROR )
+ _fwrite(buf+3, len-3, stderr);
}
void syslog(int prio, const char *format, ...)
}
void syslog(int prio, const char *format, ...)