|
|
|
@ -1,28 +1,40 @@
|
|
|
|
|
From 5acbeb7a63aa4fe1b7e9817c5ba56786a1703e06 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From 615a0b131223d471277c08f894c8f3b7091c8d10 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Emery Hemingway <ehmry@posteo.net>
|
|
|
|
|
Date: Fri, 16 Apr 2021 13:54:16 +0200
|
|
|
|
|
Subject: [PATCH] terminal_log: configurable log labels
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
repos/os/src/server/terminal_log/main.cc | 24 ++++++++++++++++--------
|
|
|
|
|
1 file changed, 16 insertions(+), 8 deletions(-)
|
|
|
|
|
repos/os/src/server/terminal_log/main.cc | 39 +++++++++++++++++-------
|
|
|
|
|
1 file changed, 28 insertions(+), 11 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/repos/os/src/server/terminal_log/main.cc b/repos/os/src/server/terminal_log/main.cc
|
|
|
|
|
index dd3cb1a46b..07f01d8da4 100644
|
|
|
|
|
index dd3cb1a46b..d5c37ff5a1 100644
|
|
|
|
|
--- a/repos/os/src/server/terminal_log/main.cc
|
|
|
|
|
+++ b/repos/os/src/server/terminal_log/main.cc
|
|
|
|
|
@@ -30,8 +30,8 @@ namespace Genode {
|
|
|
|
|
@@ -11,6 +11,8 @@
|
|
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
+#include <os/session_policy.h>
|
|
|
|
|
+#include <base/attached_rom_dataspace.h>
|
|
|
|
|
#include <root/component.h>
|
|
|
|
|
#include <base/component.h>
|
|
|
|
|
#include <base/heap.h>
|
|
|
|
|
@@ -28,9 +30,12 @@ namespace Genode {
|
|
|
|
|
|
|
|
|
|
enum { LABEL_LEN = 64 };
|
|
|
|
|
|
|
|
|
|
+ typedef Genode::String<LABEL_LEN> Label;
|
|
|
|
|
+
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
- char _label[LABEL_LEN];
|
|
|
|
|
- Terminal::Connection &_terminal;
|
|
|
|
|
+ String<LABEL_LEN> const _label;
|
|
|
|
|
+ Terminal::Connection &_terminal;
|
|
|
|
|
+ Label const _label;
|
|
|
|
|
+
|
|
|
|
|
Terminal::Connection &_terminal;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
@@ -39,7 +39,7 @@ namespace Genode {
|
|
|
|
|
@@ -39,7 +44,7 @@ namespace Genode {
|
|
|
|
|
* Constructor
|
|
|
|
|
*/
|
|
|
|
|
Termlog_component(const char *label, Terminal::Connection &terminal)
|
|
|
|
@ -31,16 +43,16 @@ index dd3cb1a46b..07f01d8da4 100644
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************
|
|
|
|
|
@@ -76,7 +76,7 @@ namespace Genode {
|
|
|
|
|
@@ -76,7 +81,7 @@ namespace Genode {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- _terminal.write(_label, strlen(_label));
|
|
|
|
|
+ _terminal.write(_label);
|
|
|
|
|
+ _terminal.write(_label.string(), _label.length());
|
|
|
|
|
_terminal.write(string, len);
|
|
|
|
|
|
|
|
|
|
/* if last character of string was not a line break, add one */
|
|
|
|
|
@@ -93,7 +93,8 @@ namespace Genode {
|
|
|
|
|
@@ -93,7 +98,8 @@ namespace Genode {
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
@ -50,25 +62,37 @@ index dd3cb1a46b..07f01d8da4 100644
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
@@ -104,8 +105,15 @@ namespace Genode {
|
|
|
|
|
@@ -102,12 +108,23 @@ namespace Genode {
|
|
|
|
|
*/
|
|
|
|
|
Termlog_component *_create_session(const char *args) override
|
|
|
|
|
{
|
|
|
|
|
char label_buf[Termlog_component::LABEL_LEN];
|
|
|
|
|
|
|
|
|
|
- char label_buf[Termlog_component::LABEL_LEN];
|
|
|
|
|
-
|
|
|
|
|
- Arg label_arg = Arg_string::find_arg(args, "label");
|
|
|
|
|
- label_arg.string(label_buf, sizeof(label_buf), "");
|
|
|
|
|
-
|
|
|
|
|
- return new (md_alloc()) Termlog_component(label_buf, _terminal);
|
|
|
|
|
+ Session_label const session_label = label_from_args(args);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ Attached_rom_dataspace config_rom(_env, "config");
|
|
|
|
|
+ Session_policy policy(session_label, config_rom.xml());
|
|
|
|
|
+ policy.attribute_value("label", label_buf, sizeof(label_buf));
|
|
|
|
|
+ } (...) {
|
|
|
|
|
+ auto label = policy.attribute_value(
|
|
|
|
|
+ "log_label", Termlog_component::Label());
|
|
|
|
|
+ return new (md_alloc())
|
|
|
|
|
+ Termlog_component(label.string(), _terminal);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (...) {
|
|
|
|
|
+ char label_buf[Termlog_component::LABEL_LEN];
|
|
|
|
|
+ snprintf(label_buf, sizeof(label_buf),
|
|
|
|
|
+ "[%s] ", session_label.string());
|
|
|
|
|
+ return new (md_alloc())
|
|
|
|
|
+ Termlog_component(label_buf, _terminal);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
return new (md_alloc()) Termlog_component(label_buf, _terminal);
|
|
|
|
|
}
|
|
|
|
|
@@ -120,7 +128,7 @@ namespace Genode {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
@@ -120,7 +137,7 @@ namespace Genode {
|
|
|
|
|
*/
|
|
|
|
|
Termlog_root(Genode::Env &env, Allocator &md_alloc)
|
|
|
|
|
: Root_component<Termlog_component>(env.ep(), md_alloc),
|
|
|
|
|