Don Angelo Annoni
Don Angelo Annoni

Reputation: 380

Can I get the names of the asserts if they happen in Qt? Console Application

I have a long running console application written in C++ (Qt). If an assert happens - my application crashes very bad. So I need to know what assert is failed. I need to know this because I have to find and fix the buggy part of the code. How can I achieve this? I don't want my application to crash, but if crashes by failed asserts - I want to know what's wrong and where. Thanks. :) PS: Can I log the assert name and the place when app crashes?

PS2: The asserts that happens are internal e.g. Qt's.

Upvotes: 0

Views: 60

Answers (1)

spiritwolfform
spiritwolfform

Reputation: 2293

You can redirect the output to a file using command-line parameters

2>&1 | tee ~/console.txt 

This will copy stderr and stdout to a txt file. Q_ASSERTS are printed to stderr so you should be able to see the output now and diagnose the problem

Upvotes: 1

Related Questions