This patch adds support for a new set of configuration options to allow
the user to change the colour presets. The predefined colour presets are
the following:
faded for debugging output
alert for important messages
highlight highlighted text
pass PASS colour
fail FAIL colour
info the INFO label
debug the DEBUG label
warning the WARNING label
error the ERROR label
log_header the date and ip address in each log message
You can override these values on both the controller and the slave by
addint a [colours] section to your conf file and setting different
values for these presets. For example:
[colours]
faded = yellow none false
alert = red none true
Each colour preset comprises of three values:
(foreground colour, background colour, bold flag)
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
lnst-ctl | 3 +++
lnst/Common/Config.py | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/lnst-ctl b/lnst-ctl
index 210c6dc..f4fc31d 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -19,6 +19,7 @@ import re
import datetime
from lnst.Common.Logs import LoggingCtl, log_exc_traceback
from lnst.Common.Config import Config
+from lnst.Common.Colours import load_presets_from_config
from lnst.Controller.NetTestController import NetTestController, NetTestError
from lnst.Controller.NetTestResultSerializer import NetTestResultSerializer
@@ -130,6 +131,8 @@ def main():
elif opt in ("-o", "--disable-pool-checks"):
pool_checks = False
+ load_presets_from_config(config)
+
date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
log_ctl = LoggingCtl(debug,
log_dir=config.get_option('environment',
'log_dir'),
diff --git a/lnst/Common/Config.py b/lnst/Common/Config.py
index 3d65048..32ea3a3 100644
--- a/lnst/Common/Config.py
+++ b/lnst/Common/Config.py
@@ -73,6 +73,8 @@ class Config():
"action" : self.optionPath,
"name" : "log_dir"}
+ self.colours_scheme()
+
def slave_scheme(self):
self.options['environment'] = dict()
self.options['environment']['log_dir'] = {\
@@ -96,6 +98,17 @@ class Config():
"action" : self.optionTimeval,
"name" : "expiration_period"}
+ self.colours_scheme()
+
+ def colours_scheme(self):
+ self.options['colours'] = dict()
+ for preset in ["default", "faded", "alert",
"highlight",
+ "pass", "fail", "error",
"info", "debug", "warning",
+ "log_header"]:
+ self.options['colours'][preset] = {\
+ "value" : None, "additive" : False,
+ "action" : self.optionColour, "name" : preset}
+
def get_config(self):
return self.options
@@ -226,6 +239,16 @@ class Config():
return timeval
+ def optionColour(self, option, cfg_path):
+ colour = option.split()
+ if len(colour) != 3:
+ msg = "Colour must be specified by 3"\
+ " values (foreground, background, bold)"\
+ " sepparated by whitespace."
+ raise ConfigError(msg)
+
+ return colour
+
def dump_config(self):
string = ""
for section in self.options:
--
1.7.7.6