Hey there =)
Today I found out on how to change the look of the OpenHAB Log viewer. I was quite tired of the old look and like the new appearance of my logs. Have a look:
On mobile this looks like this
This is the LogViewer from @cyb3rko See here
(The errors are on purpose for demonstration purposes )
The Log viewer is just an instance of frontail, an open source “Node.js application for streaming logs to the browser. It’s a
tail -F with UI.” Github
I changed the the arguments the frontail instance gets when starting and the json file responsible for some look improvements.
Edit the systemctl config with
sudo nano /etc/systemd/system/frontail.service and change the line beginning with
ExecStart. I added the dark theme option. So now my config looks like this:
ExecStart=/usr/lib/node_modules/frontail/bin/frontail --ui-highlight --ui-highlight-preset /usr/lib/node_modules/frontail/preset/openhab.json -l 10000 -n 200 -t dark /var/log/openhab2/openhab.log /var/log/openhab2/events.log
When finishing the configuration run
sudo systemctl daemon-reload; sudo service frontail restart.
Furthermore I added the highlight-preset to have all text as white and change some backgrounds
“[ERROR]”: “color: red;”,
“[WARN ]”: “color: orange;”,
“[INFO ]”: “color: #0ED600;”,
“Node is DEAD”: “color: red;”
“INFO”: “color: #FFFFFF;”,
“:”: “color: #FFFFFF;”,
“/var/log/openhab2/openhab.log”: “text-align: right; font-size: 0.8em; border-top: 2px solid #FFFFFF; color: #FFFFFF;”,
“/var/log/openhab2/events.log”: “text-align: right; font-size: 0.8em; border-top: 2px solid #FFFFFF; color: #FFFFFF;”,
“ERROR”: “color: #FFFFFF; background-color: #990000;”,
“model.script”: “background-color: #00918D; font-weight: bold; color: #FFFFFF;”
For testing purposes do
sudo nano /usr/lib/node_modules/frontail/preset/openhab.json; sudo systemctl daemon-reload; sudo service frontail restart
so you can edit and immediately see the changes.
Reload you log viewer in your web browser and your new theme is applied.
If it doesnt load dont worry! Just enter the frontail --ui-highlight […] events.log we changed earlier into the shell. Frontail will say what caused the problem. For example I had a comma to much so I got this error
$frontail --ui-highlight --ui-highlight-preset /usr/lib/node_modules/frontail/preset/openhab.json -l 10000 -n 200 -t dark /var/log/openhab2/openhab.log /var/log/openhab2/events.log
SyntaxError: Unexpected token } in JSON at position 386
Change the log viewer so it looks exactly how you like!