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

Thiago Macieira thiago.macieira at intel.com
Thu Jul 10 19:07:56 CEST 2014


On Thursday 10 July 2014 08:13:09 Koehne Kai wrote:
> > -----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.

The latest patch does not match the proposal.

I want to remove the stderr check for Unix and for Windows, which means 
Creator should check the system logs.

> 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).

Agreed it must continue to read.

As for the synchronisation, journald gives you the message's absolute 
timestamp, so you'll just need to do the same for each line read via QProcess.

> > 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.

Addressed above.

> > 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).

Creator must be able to handle reading from the system log before logging to 
the system is enabled for that system. On Linux, the code is already there, so 
we have to tell distributions *not* to enable journald yet. For OS X, it's 
putting a hold on https://codereview.qt-project.org/82922.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list