core: add support for unlabeled LOG sessions
If the root child requests a LOG service with the label "unlabeled" then return a LOG session that logs unprefixed messages. This allows a external test controller to recognize log messages produced by a blessed component.
This commit is contained in:
parent
0181c6025a
commit
bbdf181828
|
@ -28,12 +28,21 @@ namespace Genode {
|
||||||
|
|
||||||
Session_label const _label;
|
Session_label const _label;
|
||||||
|
|
||||||
|
static Session_label _expand_label(Session_label const &label)
|
||||||
|
{
|
||||||
|
if (label == "init -> unlabeled")
|
||||||
|
return "";
|
||||||
|
else
|
||||||
|
return Session_label("[", label, "] ");
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Log_session_component(Session_label const &label) : _label(label) { }
|
Log_session_component(Session_label const &label)
|
||||||
|
: _label(_expand_label(label)) { }
|
||||||
|
|
||||||
|
|
||||||
/*****************
|
/*****************
|
||||||
|
@ -53,14 +62,14 @@ namespace Genode {
|
||||||
unsigned from_i = 0;
|
unsigned from_i = 0;
|
||||||
for (unsigned i = 0; i < len; i++) {
|
for (unsigned i = 0; i < len; i++) {
|
||||||
if (string[i] == '\n') {
|
if (string[i] == '\n') {
|
||||||
log("[", _label, "] ", Cstring(string + from_i, i - from_i));
|
log(_label, Cstring(string + from_i, i - from_i));
|
||||||
from_i = i + 1;
|
from_i = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if last character of string was not a line break, add one */
|
/* if last character of string was not a line break, add one */
|
||||||
if (from_i < len)
|
if (from_i < len)
|
||||||
log("[", _label, "] ", Cstring(string + from_i));
|
log(_label, Cstring(string + from_i));
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue