PDA

View Full Version : Cannot see debug messages in a unix environment



KShots
5th March 2015, 15:54
Hey all,

I'm using Qt creator 3.3.1 under linux with Qt 5.4.1. I had been using an earlier version of Qt creator for quite a while with no issues, but I took a long break and when I came back, I updated my environment (creator updated to 3.3.1, Qt updated from 5.3.x to 5.4.1). Under this environment, all messages routed through qDebug(), qWarning, and qFatal() are not shown in the application output tab, where they had worked fine earlier. I see lots of messages about this problem being limited to Windows and to install some Windows debugging tools, but I'm not in a Windows environment. This is really slowing down my development, as I use these messages to track the state of my applications for debugging purposes (both with and without the debugger). How is everyone else working around this issue?

wysota
5th March 2015, 18:00
There is no such issue for everyone else :)

JasonC
5th March 2015, 20:03
This might be a stupid question but are you absolutely certain no other instances of Creator are running in the background (perhaps stuck)? Use ps to be sure.

Do you see anything in the console at all when you run your program? What about the initial "Starting" message when you run?

KShots
5th March 2015, 20:12
This might be a stupid question but are you absolutely certain no other instances of Creator are running in the background (perhaps stuck)? Use ps to be sure.

Do you see anything in the console at all when you run your program? What about the initial "Starting" message when you run?

I don't have any other instances running. I only get the following in the "Application Output" tab when running my application:
Starting /home/rich/build/evilrpg/src/client/evilrpg...
/home/rich/build/evilrpg/src/client/evilrpg exited with code 0If I manually run the app in a console, I get all my debug messages.

wysota
5th March 2015, 22:29
Does your program actually do what it is supposed to? It looks like it just exits.

JasonC
6th March 2015, 02:17
Try creating a new project that does nothing but print a debug message. If it works then you can narrow it down to something specific to your evilrpg program. If it doesn't work at least you'll have a minimal test case to work from.

jefftee
6th March 2015, 03:43
Does your program require any command line arguments to run and if so, are you passing those on the Project->Run settings for your project?

anda_skoa
6th March 2015, 09:51
One reason I can think of is that the new Qt detected your system is using journald for logging and directed the output there.
You can force logging to the console by setting QT_LOGGING_TO_CONSOLE=1, e.g. in the project's run environment.

Cheers,
_

KShots
6th March 2015, 16:10
Does your program actually do what it is supposed to? It looks like it just exits.

Yeah, it does. It spawns a gui, connects to a remote server, and if I run it in a console, it tells me all about the various stages it's going through with the network traffic. When run in Qt-Creator, the above is all I get (with the application itself running).

Added after 4 minutes:


One reason I can think of is that the new Qt detected your system is using journald for logging and directed the output there.
You can force logging to the console by setting QT_LOGGING_TO_CONSOLE=1, e.g. in the project's run environment.

Cheers,
_

I had almost forgotten about that. I built it from the gentoo ebuild, which may or may not have redirected the log to journald (I do run systemd). That appears to have resolved it, though. Thanks!

[EDIT]

I'm rather confused why this worked. Why am I getting output in my consoles without the environment variable? I was under the impression that nothing would hit stdout/stderr if journald was used, yet I have messages in my console. Am I misunderstanding how the journald interface works?

JasonC
7th March 2015, 06:53
I'm rather confused why this worked. Why am I getting output in my consoles without the environment variable? I was under the impression that nothing would hit stdout/stderr if journald was used, yet I have messages in my console. Am I misunderstanding how the journald interface works?

When QT_LOGGING_TO_CONSOLE is not specified, Qt essentially tries to guess if you're running in a terminal or not to determine where to send the logs. Terminal = stderr, anything else = whatever your Qt installation is configured to support (e.g. journald).

Afaict, this behavior was introduced in Qt 5.4. See https://codereview.qt-project.org/#/c/89357/, in particular:


This commit adds logic similar to Windows's: if the application has a controlling TTY, we'll use stderr. Otherwise, we'll use the system log. This is technically a change in behavior: previously, we would always use the system log, unless the environment variable told us not to.

The environment variable can always be specified to force one or the other, but if it's not specified, a choice is made automatically.

For more information see:
http://lists.qt-project.org/pipermail/development/2014-July/017588.html (discussion with some rationale for above change)
http://stackoverflow.com/questions/26295325/where-is-located-the-qdebug-qwarning-qcritical-and-qfatal-log-by-default-on-qt (a mostly good summary)