mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 20:05:54 +00:00
base: append label per line properly (log service)
If newlines are in the string send to the core log service, they don't get the label properly appended before each output. The messages then look like they are coming from core. Fixes #1368
This commit is contained in:
parent
25eec75ad8
commit
336018b493
@ -52,7 +52,7 @@ namespace Genode {
|
||||
}
|
||||
|
||||
char const *string = string_buf.string();
|
||||
int len = strlen(string);
|
||||
size_t len = strlen(string);
|
||||
|
||||
/*
|
||||
* Heuristic: The Log console implementation flushes
|
||||
@ -70,11 +70,21 @@ namespace Genode {
|
||||
return len;
|
||||
}
|
||||
|
||||
printf("[%s] %s", _label, string);
|
||||
char buf[string_buf.MAX_SIZE];
|
||||
unsigned from_i = 0;
|
||||
|
||||
for (unsigned i = 0; i < len; i++) {
|
||||
if (string[i] == '\n') {
|
||||
memcpy(buf, string + from_i, i - from_i);
|
||||
buf[i - from_i] = 0;
|
||||
printf("[%s] %s\n", _label, buf);
|
||||
from_i = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* if last character of string was not a line break, add one */
|
||||
if ((len > 0) && (string[len - 1] != '\n'))
|
||||
printf("\n");
|
||||
if (from_i < len)
|
||||
printf("[%s] %s\n", _label, string + from_i);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user