From bbdf18182864336dcbb9972f3bebca6c1de71300 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 29 Jan 2020 12:17:40 +0100 Subject: [PATCH] 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. --- .../base/src/core/include/log_session_component.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/repos/base/src/core/include/log_session_component.h b/repos/base/src/core/include/log_session_component.h index 3ed806f29..29bda822c 100644 --- a/repos/base/src/core/include/log_session_component.h +++ b/repos/base/src/core/include/log_session_component.h @@ -28,12 +28,21 @@ namespace Genode { Session_label const _label; + static Session_label _expand_label(Session_label const &label) + { + if (label == "init -> unlabeled") + return ""; + else + return Session_label("[", label, "] "); + } + public: /** * 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; for (unsigned i = 0; i < len; i++) { 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; } } /* if last character of string was not a line break, add one */ if (from_i < len) - log("[", _label, "] ", Cstring(string + from_i)); + log(_label, Cstring(string + from_i)); return len; }