I'm using qSetMessagePattern to format the output.
The weird thing is even I set %{file} and %{line}, I could only get unknown and 0 in my output. And so does the %{function}. The source and output are below:
qSetMessagePattern("%{file}(%{line}): %{message}");
qDebug() << "msg";
output:
unknown(0): msg
Any ideas? Thanks!
Try to add for the target you build:
target_compile_definitions(${PROJECT_NAME} PRIVATE -DQT_DEBUG -DQT_MESSAGELOGCONTEXT)
Seems -DQT_DEBUG has priority when used along with -DQT_NO_DEBUG.
add
DEFINES += QT_MESSAGELOGCONTEXT
to your xxx.pro,
and then, rebuild
make clean && make distclean && qmake && make
I hope this could help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With