Patch terminal_log to override log labels
When generating configuration with Dhall it is simpler to specify a policy rather than rewrite a session label.post-mortem
parent
fb35449420
commit
0d5650d39c
@ -0,0 +1,82 @@
|
||||
From 5acbeb7a63aa4fe1b7e9817c5ba56786a1703e06 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(-)
|
||||
|
||||
diff --git a/repos/os/src/server/terminal_log/main.cc b/repos/os/src/server/terminal_log/main.cc
|
||||
index dd3cb1a46b..07f01d8da4 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 {
|
||||
|
||||
private:
|
||||
|
||||
- char _label[LABEL_LEN];
|
||||
- Terminal::Connection &_terminal;
|
||||
+ String<LABEL_LEN> const _label;
|
||||
+ Terminal::Connection &_terminal;
|
||||
|
||||
public:
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Genode {
|
||||
* Constructor
|
||||
*/
|
||||
Termlog_component(const char *label, Terminal::Connection &terminal)
|
||||
- : _terminal(terminal) { snprintf(_label, LABEL_LEN, "[%s] ", label); }
|
||||
+ : _label(label), _terminal(terminal) { }
|
||||
|
||||
|
||||
/*****************
|
||||
@@ -76,7 +76,7 @@ namespace Genode {
|
||||
return;
|
||||
}
|
||||
|
||||
- _terminal.write(_label, strlen(_label));
|
||||
+ _terminal.write(_label);
|
||||
_terminal.write(string, len);
|
||||
|
||||
/* if last character of string was not a line break, add one */
|
||||
@@ -93,7 +93,8 @@ namespace Genode {
|
||||
{
|
||||
private:
|
||||
|
||||
- Terminal::Connection _terminal;
|
||||
+ Genode::Env &_env;
|
||||
+ Terminal::Connection _terminal { _env, "log" };
|
||||
|
||||
protected:
|
||||
|
||||
@@ -104,8 +105,15 @@ namespace Genode {
|
||||
{
|
||||
char label_buf[Termlog_component::LABEL_LEN];
|
||||
|
||||
- Arg label_arg = Arg_string::find_arg(args, "label");
|
||||
- label_arg.string(label_buf, sizeof(label_buf), "");
|
||||
+ 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));
|
||||
+ } (...) {
|
||||
+ snprintf(label_buf, sizeof(label_buf),
|
||||
+ "[%s] ", session_label.string());
|
||||
+ }
|
||||
|
||||
return new (md_alloc()) Termlog_component(label_buf, _terminal);
|
||||
}
|
||||
@@ -120,7 +128,7 @@ namespace Genode {
|
||||
*/
|
||||
Termlog_root(Genode::Env &env, Allocator &md_alloc)
|
||||
: Root_component<Termlog_component>(env.ep(), md_alloc),
|
||||
- _terminal(env, "log") { }
|
||||
+ _env(env) { }
|
||||
};
|
||||
}
|
||||
|
||||
--
|
||||
2.31.0
|
||||
|
Loading…
Reference in New Issue