[Development] Cake and eating it too for qDebug printing to system log - https://codereview.qt-project.org/89357

Koehne Kai Kai.Koehne at digia.com
Thu Jul 10 10:13:09 CEST 2014



> -----Original Message-----
> From: development-bounces+kai.koehne=digia.com at qt-project.org
> [...]
> Here's what I propose:
> 
> Heuristically determine at runtime. On all platforms (including Windows), use
> only the fact that a terminal is present. If a terminal is present, write to it
> using stderr. Otherwise, write to the system log.
> 
> * Implications for Qt Creator:
> 1) it must be able to read from the system log for desktop debugging
> (especially when running applications without "Run in terminal"). That's
> already done on Windows. It will be necessary to add support for journald
> (Linux) and asl (OS X).

Well, actually your latest patch that checks for "stderr!=/dev/null" will just work fine with current Qt Creator. That's for journal/Linux at least, haven't had a look yet how asl works.

Qt Creator needs to continue listening to stderr in any case: You still want to see stdout/stderr, after all. It's true that Qt Creator can in theory profit from additional information piped through systemd, but integrating both streams also has it's issues: E.g. the order of qDebug/stderr messages is no longer consistent, and interleaving lines might need special attention (though I guess we handle that already for stdout/stderr).

> 2) remote debugging: per platform, it needs to be decided whether we can
> access the log on the remote device. If so, that's the best situation. If it isn't,
> then we need to force Qt to log to stderr.
> 
>  2a) set QT_LOGGING_TO_CONSOLE=1 in the environment
>  2b) force the allocation of a terminal (if using ssh, pass the -t option)

See above. Unless stderr somehow ends up in the system log too we need to anyway have the terminal.
 
> I recommend advising Linux distributions to disable journald logging at least
> until Creator is updated. And the support for asl on OSX should be held until
> the same time.

I agree (though I'm not sure whether Qt Creator is the blocker, or if it's enough to handle the issue in Qt. See above).

> * Implications for unit tests:
> Except for the unit tests testing logging to the system log in the first place,
> QT_LOGGING_TO_CONSOLE=1 should be set. I think QtTest itself should do
> that.
> 
> * Support for journald in the pre-built Creator binary:
> 1) new plugin, link to libsystemd-journal.so.0. If the library isn't present in the
> target system, the plugin won't load.
> 
> 2) dlopen libsystemd-journal.so.0. If it isn't present, then Qt can't very well
> be logging to it.
> 
> 3) use QProcess to run journalctl -f
> 
> * Support for journald in the pre-built Qt binaries:
> Disabled.
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list