[Development] Cake and eating it too for qDebug printing to system log - https://codereview.qt-project.org/89357
suy at badopi.org
Fri Jul 11 07:45:23 CEST 2014
El Friday 11 July 2014, Lisandro Damián Nicanor Pérez Meyer escribió:
> AFAIU from this thread, journald support should not be enabled except
> "regular users can read the output". Now what I'm missing here is: if Qt
> is built with journald support, can it be still be used if journald is not
No. Quote from:
"If systemd-journald(8) is not running (the socket is not present), those
functions do nothing, and also return 0."
> Yes, I happen to be maintaining Qt for a distro in which users can still
> choose the init system.
And unfortunately, there is no clean way to test for it. There is the
sd_booted() function, but:
"Internally, this function checks whether the directory /run/systemd/system/
exists. A simple check like this can also be implemented trivially in shell or
any other language."
Which wasn't enough in my tests. Since I used systemd to boot the (developer)
system, but I ran the app on Creator, it would return true all the time, and I
got no output on Creator.
It might be even worse if systemd-shim provides that directory. Is it worth to
try sd_journal_open() and see if it fails? Or check some other way if systemd
actually launched the application?
Also, the way is done now (more after the patch on review) is to check for the
console first, and then the decision is done. If the heuristics to find a
console are good enough for you, having journald support is irrelevant, since
if you are in a console you'll get the stderr printing.
Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
http://barnacity.net/ | http://disperso.net
More information about the Development