[windows] Set QsDebugOutput to console
If QsLog is included inside a project with CONFIG+=console
the QsDebugOutput
don't write anything in console in Release builds.
I make it works removing Q_OS_WIN
specific QsDebugOutput::output
function and using Q_OS_UNIX
one.
I don't know if it is a bug or a feature. In the second case, how do I print log in console even in Release ?
Comments (5)
-
repo owner -
reporter QtCreator does intercept these messages very well too.
Console logs is for users to show what happens while running. I did theses change:
void QsDebugOutput::output( const QString& message ) { #if defined(QT_DEBUG) OutputDebugStringW(reinterpret_cast<const WCHAR*>(message.utf16())); OutputDebugStringW(L"\n"); #else fprintf(stderr, "%s\n", qPrintable(message)); fflush(stderr); #endif // QT_DEBUG }
Do you think it can be added in QsLog directly or would I keep this on my own ?
-
repo owner I cannot include the code as is, but I can probably add a new preprocessor define, such as WINDOWS_USE_PRINTF_FOR_DEBUG_OUTPUT.
-
reporter That sound a bit heavy to me. Maybe a dedicated destination should be clearer. Currently,
QsLogDestConsole
implements Debug ouput, but what if it implements a real console output and adding aQsLogDestDebug
class ? -
repo owner - changed status to resolved
Uncommenting QS_LOG_WIN_PRINTF_CONSOLE in QsLog.pri will enable fprintf-based console output on Windows.
Adding a new destination would have been significantly more effort, because each debugger would probably have its own way of receiving messages.
- Log in to comment
Hi Alexandre, this was a design decision when building QsLog, the console output on Windows will log to e.g the Visual Studio debugger console, not to stdout/stderr. I think QtCreator can also intercept these messages and show them in the application output view.
Are the console logs something that the users of your program are interested in, or do you just use them yourself?
to the
QsDebugOutput::output
function for theQ_OS_WIN
case.