Patch from Larry Doolittle, fix up logging across multilple lines, hopefully
fixing bug #1061.
This commit is contained in:
parent
70d09ed1cf
commit
cf7982e908
@ -403,7 +403,8 @@ static void doKlogd (void)
|
|||||||
{
|
{
|
||||||
int priority = LOG_INFO;
|
int priority = LOG_INFO;
|
||||||
char log_buffer[4096];
|
char log_buffer[4096];
|
||||||
char *logp;
|
int i, n, lastc;
|
||||||
|
char *start;
|
||||||
|
|
||||||
/* Set up sig handlers */
|
/* Set up sig handlers */
|
||||||
signal(SIGINT, klogd_signal);
|
signal(SIGINT, klogd_signal);
|
||||||
@ -420,12 +421,14 @@ static void doKlogd (void)
|
|||||||
logMessage(0, "klogd started: "
|
logMessage(0, "klogd started: "
|
||||||
"BusyBox v" BB_VER " (" BB_BT ")");
|
"BusyBox v" BB_VER " (" BB_BT ")");
|
||||||
|
|
||||||
|
/* "Open the log. Currently a NOP." */
|
||||||
klogctl(1, NULL, 0);
|
klogctl(1, NULL, 0);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Use kernel syscalls */
|
/* Use kernel syscalls */
|
||||||
memset(log_buffer, '\0', sizeof(log_buffer));
|
memset(log_buffer, '\0', sizeof(log_buffer));
|
||||||
if (klogctl(2, log_buffer, sizeof(log_buffer)) < 0) {
|
n = klogctl(2, log_buffer, sizeof(log_buffer));
|
||||||
|
if (n < 0) {
|
||||||
char message[80];
|
char message[80];
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@ -435,37 +438,29 @@ static void doKlogd (void)
|
|||||||
logMessage(LOG_SYSLOG | LOG_ERR, message);
|
logMessage(LOG_SYSLOG | LOG_ERR, message);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
logp = log_buffer;
|
|
||||||
if (*log_buffer == '<') {
|
/* klogctl buffer parsing modelled after code in dmesg.c */
|
||||||
switch (*(log_buffer + 1)) {
|
start=&log_buffer[0];
|
||||||
case '0':
|
lastc='\0';
|
||||||
priority = LOG_EMERG;
|
for (i=0; i<n; i++) {
|
||||||
break;
|
if (lastc == '\0' && log_buffer[i] == '<') {
|
||||||
case '1':
|
priority = 0;
|
||||||
priority = LOG_ALERT;
|
i++;
|
||||||
break;
|
while (isdigit(log_buffer[i])) {
|
||||||
case '2':
|
priority = priority*10+(log_buffer[i]-'0');
|
||||||
priority = LOG_CRIT;
|
i++;
|
||||||
break;
|
}
|
||||||
case '3':
|
if (log_buffer[i] == '>') i++;
|
||||||
priority = LOG_ERR;
|
start = &log_buffer[i];
|
||||||
break;
|
|
||||||
case '4':
|
|
||||||
priority = LOG_WARNING;
|
|
||||||
break;
|
|
||||||
case '5':
|
|
||||||
priority = LOG_NOTICE;
|
|
||||||
break;
|
|
||||||
case '6':
|
|
||||||
priority = LOG_INFO;
|
|
||||||
break;
|
|
||||||
case '7':
|
|
||||||
default:
|
|
||||||
priority = LOG_DEBUG;
|
|
||||||
}
|
}
|
||||||
logp += 3;
|
if (log_buffer[i] == '\n') {
|
||||||
|
log_buffer[i] = '\0'; /* zero terminate this message */
|
||||||
|
logMessage(LOG_KERN | priority, start);
|
||||||
|
start = &log_buffer[i+1];
|
||||||
|
priority = LOG_INFO;
|
||||||
|
}
|
||||||
|
lastc = log_buffer[i];
|
||||||
}
|
}
|
||||||
logMessage(LOG_KERN | priority, logp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
57
syslogd.c
57
syslogd.c
@ -403,7 +403,8 @@ static void doKlogd (void)
|
|||||||
{
|
{
|
||||||
int priority = LOG_INFO;
|
int priority = LOG_INFO;
|
||||||
char log_buffer[4096];
|
char log_buffer[4096];
|
||||||
char *logp;
|
int i, n, lastc;
|
||||||
|
char *start;
|
||||||
|
|
||||||
/* Set up sig handlers */
|
/* Set up sig handlers */
|
||||||
signal(SIGINT, klogd_signal);
|
signal(SIGINT, klogd_signal);
|
||||||
@ -420,12 +421,14 @@ static void doKlogd (void)
|
|||||||
logMessage(0, "klogd started: "
|
logMessage(0, "klogd started: "
|
||||||
"BusyBox v" BB_VER " (" BB_BT ")");
|
"BusyBox v" BB_VER " (" BB_BT ")");
|
||||||
|
|
||||||
|
/* "Open the log. Currently a NOP." */
|
||||||
klogctl(1, NULL, 0);
|
klogctl(1, NULL, 0);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Use kernel syscalls */
|
/* Use kernel syscalls */
|
||||||
memset(log_buffer, '\0', sizeof(log_buffer));
|
memset(log_buffer, '\0', sizeof(log_buffer));
|
||||||
if (klogctl(2, log_buffer, sizeof(log_buffer)) < 0) {
|
n = klogctl(2, log_buffer, sizeof(log_buffer));
|
||||||
|
if (n < 0) {
|
||||||
char message[80];
|
char message[80];
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@ -435,37 +438,29 @@ static void doKlogd (void)
|
|||||||
logMessage(LOG_SYSLOG | LOG_ERR, message);
|
logMessage(LOG_SYSLOG | LOG_ERR, message);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
logp = log_buffer;
|
|
||||||
if (*log_buffer == '<') {
|
/* klogctl buffer parsing modelled after code in dmesg.c */
|
||||||
switch (*(log_buffer + 1)) {
|
start=&log_buffer[0];
|
||||||
case '0':
|
lastc='\0';
|
||||||
priority = LOG_EMERG;
|
for (i=0; i<n; i++) {
|
||||||
break;
|
if (lastc == '\0' && log_buffer[i] == '<') {
|
||||||
case '1':
|
priority = 0;
|
||||||
priority = LOG_ALERT;
|
i++;
|
||||||
break;
|
while (isdigit(log_buffer[i])) {
|
||||||
case '2':
|
priority = priority*10+(log_buffer[i]-'0');
|
||||||
priority = LOG_CRIT;
|
i++;
|
||||||
break;
|
}
|
||||||
case '3':
|
if (log_buffer[i] == '>') i++;
|
||||||
priority = LOG_ERR;
|
start = &log_buffer[i];
|
||||||
break;
|
|
||||||
case '4':
|
|
||||||
priority = LOG_WARNING;
|
|
||||||
break;
|
|
||||||
case '5':
|
|
||||||
priority = LOG_NOTICE;
|
|
||||||
break;
|
|
||||||
case '6':
|
|
||||||
priority = LOG_INFO;
|
|
||||||
break;
|
|
||||||
case '7':
|
|
||||||
default:
|
|
||||||
priority = LOG_DEBUG;
|
|
||||||
}
|
}
|
||||||
logp += 3;
|
if (log_buffer[i] == '\n') {
|
||||||
|
log_buffer[i] = '\0'; /* zero terminate this message */
|
||||||
|
logMessage(LOG_KERN | priority, start);
|
||||||
|
start = &log_buffer[i+1];
|
||||||
|
priority = LOG_INFO;
|
||||||
|
}
|
||||||
|
lastc = log_buffer[i];
|
||||||
}
|
}
|
||||||
logMessage(LOG_KERN | priority, logp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user