Qt Based Journald API Abstraction (& yet another journald browser)

On modern Linux systems usually you will find systemd as init system. Along with it, there comes journald as a logging backend with many nice and cool features (which I will not tell you anymore about, the Internet will have answers for you 😉 ). But also when you are looking on embedded devices with the power of a smart phone or like a Raspberry Pi, journald is a really nice logging data sink for you.

When analyzing logs of embedded devices, usually you are not working on the device “directly”, meaning not using the tiny konsole application of your smart phone to browse through the logs. Instead, you are either (1) grabbing the full log database from there for offline analysis or (2) you read the logs online via a network stream. Both is easily doable with journald. For the first use case you can simply (please remember to configure journald to use persistent logs!) copy the database from /var/logs/journal and access them on your developer system via “journalctl -D <path>” and get all the nice processing tooling from journalctrl — journalctl is the default CLI frontent for journald. For the second variant, you can start the journal remote service on the target device and receive the online stream of log information on your host system for analysis.

For the second case there are a few GUI applications available, which nicely solve this problem for you, e.g. qjournalctl (which parses the journalctl CLI input/output) or ksystemlog (yet with the focus of being a generic front-end for various log sinks). Yet, both do not support the parsing of non-system offline logs.

KJournald

This was the trigger for my new pet-project “kjournald“, which is meant as a Qt based model/view abstraction API for the journald C-style API. The goal is to provide an abstraction that allows easy creation of QtQuick applications that then provide journald browsing functionalities. I can think of some use cases, like a small Plasma KCM in the system settings or even something for Plasma Mobile, such that you have basic (or advanced, if you want 🙂 ) log browsing capabilities directly on your smart phone. Moreover, I imagine that this might be a possible replacement for existing places that also use journald data, but with a small self-contained and unit-tested library.

Journald-Browser

With the main goal to test my own API and providing a reference usage of the library, there is also a journald-browser application provided. At the moment, I do not see it as a stand-alone product but only to show that a full journald browser can be built with a few hundred lines of QML and a little bit of C++ gluing code.

Current state of the journald-browser: unit filter, priority filter, boot selection, rainbow coloring, basic highlight support; work for system logs and offline logs.

Current State

Everything is still in an early project state, yet all unit tests pass 🙂 This means that the API is not stable and I know many areas for improvement, especially in the browser application. But on the other hand, I am using it daily to analyze journald logs that I get into my hands and for me it is quite helpful.

Since my focus originally was on offline logs, those are the type of logs for which the support works quite well right now. But both online local journals (ie. new log entries are attached while the log is open) as well as remote logs will join soon.

Please feel free to pull it, patch it and provide features and bugfixes back!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s