Enabling the Error view
Error view in action
Release 77 will introduce the
view for the logs.
the log viewer happens to be one of the most complex parts of Bvckup 2. It looks simple, but on the back it is anything but.
Log files are created by the backup engine, but displayed by the UI module. In desktop mode this is easy enough to handle, but in service mode the engine runs in a process of its own and under a different user account, meaning the logs are simply inaccessible to the UI.
So what ends up happening is that the engine opens logs on behalf of the UI and passes open file handles back to it.
PS. Ever wondered what all those "process" handles are doing on the
argument list? Exactly to allow one process to do something privileged on behalf another process.
Log files are
, so what you see in the UI is actually a seamlessly glued together list of all log entries across all copies of a backup log.
This would've not been a big deal if it weren't for...
, the UI needs to expand/collapse log parts and do it nearly instantaneously. This is a hard problem, especially considering that logs can grow very big.
As the engine writes out the logs, the UI scans them and creates an auxiliary index, which it then uses to quickly understand what should and should not be shown in any given state.
These ndecies cannot be kept in memory, not in full. Instead the UI stores them in a specialized on-disk database, which too needs to be very quick.
However, all this complexity had a nice little side-effect. It made adding the
All the UI had to do is to build another index and include just the error entries and their immediate context. This way switching to/from the Error view is a simple matter of swapping one index file for another. That's it.
This might not be the most exciting thing ever, but still has some elegance to it, doesn't it?