mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 04:03:36 +08:00
log: handle multi-line log messages properly
This commit is contained in:
parent
b6dbbe1c98
commit
9726b29e98
6
fixme
6
fixme
@ -46,8 +46,9 @@
|
||||
|
||||
- uuidd DONE
|
||||
- nscd DONE
|
||||
- dbus DONE
|
||||
- rpcbind (/var/run/rpcbind.sock!)
|
||||
- dbus
|
||||
- avahi-daemon (/var/run/avahi-daemon/socket)
|
||||
- rsyslog
|
||||
- cups
|
||||
- ssh CLASSIC
|
||||
@ -55,7 +56,6 @@
|
||||
- apache/samba
|
||||
- libvirtd (/var/run/libvirt/libvirt-sock-ro)
|
||||
- bluetoothd (/var/run/sdp! @/org/bluez/audio!)
|
||||
- avahi-daemon (/var/run/avahi-daemon/socket)
|
||||
- distccd
|
||||
|
||||
* teach dbus to talk to systemd when autospawning services
|
||||
@ -63,6 +63,8 @@
|
||||
* Figure out which signal handlers we actually have to reset in the
|
||||
forked off child
|
||||
|
||||
* loopback-setup is borked for ipv6
|
||||
|
||||
Regularly:
|
||||
|
||||
* look for close() vs. close_nointr() vs. close_nointr_nofail()
|
||||
|
56
src/log.c
56
src/log.c
@ -312,31 +312,49 @@ static int log_dispatch(
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *buffer) {
|
||||
char *buffer) {
|
||||
|
||||
int r;
|
||||
int r = 0;
|
||||
|
||||
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
|
||||
log_target == LOG_TARGET_SYSLOG) {
|
||||
do {
|
||||
char *e;
|
||||
int k;
|
||||
|
||||
if ((r = write_to_syslog(level, file, line, func, buffer)) < 0) {
|
||||
log_close_syslog();
|
||||
log_open_kmsg();
|
||||
} else if (r > 0)
|
||||
return r;
|
||||
}
|
||||
buffer += strspn(buffer, NEWLINE);
|
||||
|
||||
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
|
||||
log_target == LOG_TARGET_KMSG) {
|
||||
if (buffer[0] == 0)
|
||||
break;
|
||||
|
||||
if ((r = write_to_kmsg(level, file, line, func, buffer)) < 0) {
|
||||
log_close_kmsg();
|
||||
log_open_console();
|
||||
} else if (r > 0)
|
||||
return r;
|
||||
}
|
||||
if ((e = strpbrk(buffer, NEWLINE)))
|
||||
*(e++) = 0;
|
||||
|
||||
return write_to_console(level, file, line, func, buffer);
|
||||
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
|
||||
log_target == LOG_TARGET_SYSLOG) {
|
||||
|
||||
if ((r = write_to_syslog(level, file, line, func, buffer)) < 0) {
|
||||
log_close_syslog();
|
||||
log_open_kmsg();
|
||||
} else if (r > 0)
|
||||
r++;
|
||||
}
|
||||
|
||||
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
|
||||
log_target == LOG_TARGET_KMSG) {
|
||||
|
||||
if ((r = write_to_kmsg(level, file, line, func, buffer)) < 0) {
|
||||
log_close_kmsg();
|
||||
log_open_console();
|
||||
} else if (r > 0)
|
||||
r++;
|
||||
}
|
||||
|
||||
if ((k = write_to_console(level, file, line, func, buffer)) < 0)
|
||||
return k;
|
||||
|
||||
buffer = e;
|
||||
} while (buffer);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int log_meta(
|
||||
|
Loading…
Reference in New Issue
Block a user