Skip to content

Commit b6be6a0

Browse files
committed
Move away from qDebug for application-specific debug information so you get output without all the Qt level debug even in release mode
1 parent 9bcd6c1 commit b6be6a0

File tree

9 files changed

+172
-74
lines changed

9 files changed

+172
-74
lines changed

tools/ld-analyse/closedcaptionsdialog.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "closedcaptionsdialog.h"
1212
#include "ui_closedcaptionsdialog.h"
13+
#include "logging.h"
1314

1415
ClosedCaptionsDialog::ClosedCaptionsDialog(QWidget *parent) :
1516
QDialog(parent),
@@ -34,7 +35,7 @@ ClosedCaptionsDialog::~ClosedCaptionsDialog()
3435

3536
void ClosedCaptionsDialog::addData(qint32 frameNumber, qint32 data0, qint32 data1)
3637
{
37-
qDebug() << "ClosedCaptionsDialog::addData: Frame number" << frameNumber << "data0 =" << data0 << "data1 =" << data1;
38+
tbcDebugStream() << "ClosedCaptionsDialog::addData: Frame number" << frameNumber << "data0 =" << data0 << "data1 =" << data1;
3839

3940
// Check that we have a continuous stream of frames
4041
if (frameNumber == lastFrameNumber) return;
@@ -49,7 +50,7 @@ void ClosedCaptionsDialog::addData(qint32 frameNumber, qint32 data0, qint32 data
4950
if (data0 == lastNonDisplayCommand && data1 == lastDisplayCommand) {
5051
// This is a command repeat; ignore
5152
} else {
52-
qDebug() << "ClosedCaptionsDialog::addData(): Got non-display control code of" << data0;
53+
tbcDebugStream() << "ClosedCaptionsDialog::addData(): Got non-display control code of" << data0;
5354
processCommand(data0, data1);
5455
lastNonDisplayCommand = data0;
5556
lastDisplayCommand = data1;
@@ -90,75 +91,75 @@ void ClosedCaptionsDialog::processCommand(qint32 data0, qint32 data1)
9091
// Normal command
9192
switch (commandType) {
9293
case 0:
93-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Resume caption loading";
94+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Resume caption loading";
9495
ui->captionTextEdit->moveCursor (QTextCursor::End);
9596
ui->captionTextEdit->insertPlainText(" ");
9697
ui->captionTextEdit->moveCursor (QTextCursor::End);
9798
break;
9899
case 1:
99-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Backspace";
100+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Backspace";
100101
break;
101102
case 2:
102-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Reserved 1";
103+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Reserved 1";
103104
ui->captionTextEdit->moveCursor (QTextCursor::End);
104105
ui->captionTextEdit->insertPlainText(" ");
105106
ui->captionTextEdit->moveCursor (QTextCursor::End);
106107
break;
107108
case 3:
108-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Reserved 2";
109+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Reserved 2";
109110
break;
110111
case 4:
111-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Delete to end of row";
112+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Delete to end of row";
112113
ui->captionTextEdit->moveCursor (QTextCursor::End);
113114
ui->captionTextEdit->insertPlainText(" ");
114115
ui->captionTextEdit->moveCursor (QTextCursor::End);
115116
break;
116117
case 5:
117-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Roll-up captions, 2 rows";
118+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Roll-up captions, 2 rows";
118119
break;
119120
case 6:
120-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Roll-up captions, 3 rows";
121+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Roll-up captions, 3 rows";
121122
break;
122123
case 7:
123-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Roll-up captions, 4 rows";
124+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Roll-up captions, 4 rows";
124125
break;
125126
case 8:
126-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Flash on";
127+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Flash on";
127128
break;
128129
case 9:
129-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Resume direct captioning";
130+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Resume direct captioning";
130131
break;
131132
case 10:
132-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Text restart";
133+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Text restart";
133134
break;
134135
case 11:
135-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Resume text display";
136+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Resume text display";
136137
break;
137138
case 12:
138-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Erase displayed memory";
139+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Erase displayed memory";
139140
break;
140141
case 13:
141-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Carriage return";
142+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Carriage return";
142143
break;
143144
case 14:
144-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Erase non-displayed memory";
145+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Erase non-displayed memory";
145146
break;
146147
case 15:
147-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - End of caption (flip memories)";
148+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - End of caption (flip memories)";
148149
ui->captionTextEdit->append("");
149150
break;
150151
}
151152
} else {
152153
// Tab offset command
153154
switch (commandType) {
154155
case 1:
155-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Tab offset (1 column)";
156+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Tab offset (1 column)";
156157
break;
157158
case 2:
158-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Tab offset (2 columns)";
159+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Tab offset (2 columns)";
159160
break;
160161
case 3:
161-
qDebug() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Tab offset (3 columns)";
162+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Miscellaneous command - Tab offset (3 columns)";
162163
break;
163164
}
164165
}
@@ -169,7 +170,7 @@ void ClosedCaptionsDialog::processCommand(qint32 data0, qint32 data1)
169170

170171
// Check for midrow command code (indicated by data0 & 01110111 == 00010001)
171172
if ((data0 & 0x77) == 0x11) {
172-
qDebug() << "ClosedCaptionsDialog::processCommand(): Midrow command";
173+
tbcDebugStream() << "ClosedCaptionsDialog::processCommand(): Midrow command";
173174

174175
// Done
175176
return;
@@ -191,7 +192,7 @@ void ClosedCaptionsDialog::processCommand(qint32 data0, qint32 data1)
191192
//qint32 displayU = (data1 & 0x01); // 0b00000001;
192193

193194
} else {
194-
qDebug() << "ClosedCaptionsDialog::addData(): Display control code invalid!" << data1;
195+
tbcDebugStream() << "ClosedCaptionsDialog::addData(): Display control code invalid!" << data1;
195196
}
196197
}
197198

tools/ld-analyse/configuration.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
******************************************************************************/
1010

1111
#include "configuration.h"
12+
#include "logging.h"
1213

1314
// This define should be incremented if the settings file format changes
1415
static const qint32 SETTINGSVERSION = 5;
@@ -28,8 +29,8 @@ Configuration::Configuration(QObject *parent) : QObject(parent)
2829

2930
// Are the configuration settings valid?
3031
if (settings.version != SETTINGSVERSION) {
31-
qDebug() << "Configuration::Configuration(): Configuration invalid or wrong version (" <<
32-
settings.version << "!= " << SETTINGSVERSION <<"). Setting to default values";
32+
tbcDebugStream() << "Configuration::Configuration(): Configuration invalid or wrong version ("
33+
<< settings.version << "!=" << SETTINGSVERSION << "). Setting to default values";
3334

3435
// Set default configuration
3536
setDefault();
@@ -75,13 +76,13 @@ void Configuration::writeConfiguration(void)
7576
configuration->endGroup();
7677

7778
// Sync the settings with disk
78-
qDebug() << "Configuration::writeConfiguration(): Writing configuration to disk";
79+
tbcDebugStream() << "Configuration::writeConfiguration(): Writing configuration to disk";
7980
configuration->sync();
8081
}
8182

8283
void Configuration::readConfiguration(void)
8384
{
84-
qDebug() << "Configuration::readConfiguration(): Reading configuration from" << configuration->fileName();
85+
tbcDebugStream() << "Configuration::readConfiguration(): Reading configuration from" << configuration->fileName();
8586

8687
// Read the valid configuration flag
8788
settings.version = configuration->value("version").toInt();

tools/ld-analyse/mainwindow.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "mainwindow.h"
1313
#include "ui_mainwindow.h"
14-
#include <QDebug>
14+
#include "logging.h"
1515

1616
MainWindow::MainWindow(QString inputFilenameParam, QWidget *parent) :
1717
QMainWindow(parent),
@@ -754,7 +754,7 @@ void MainWindow::sanitizeCurrentPosition()
754754

755755
void MainWindow::on_actionExit_triggered()
756756
{
757-
qDebug() << "MainWindow::on_actionExit_triggered(): Called";
757+
tbcDebugStream() << "MainWindow::on_actionExit_triggered(): Called";
758758

759759
// Quit the application
760760
qApp->quit();
@@ -763,7 +763,7 @@ void MainWindow::on_actionExit_triggered()
763763
// Load a TBC file based on the file selection from the GUI
764764
void MainWindow::on_actionOpen_TBC_file_triggered()
765765
{
766-
qDebug() << "MainWindow::on_actionOpen_TBC_file_triggered(): Called";
766+
tbcDebugStream() << "MainWindow::on_actionOpen_TBC_file_triggered(): Called";
767767

768768
QString inputFileName = QFileDialog::getOpenFileName(this,
769769
tr("Open TBC file"),
@@ -860,7 +860,7 @@ void MainWindow::on_actionWhite_SNR_analysis_triggered()
860860
// Save current frame as PNG
861861
void MainWindow::on_actionSave_frame_as_PNG_triggered()
862862
{
863-
qDebug() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Called";
863+
tbcDebugStream() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Called";
864864

865865
// Create a suggestion for the filename
866866
QString filenameSuggestion = configuration.getPngDirectory();
@@ -907,7 +907,7 @@ void MainWindow::on_actionSave_frame_as_PNG_triggered()
907907
// Was a filename specified?
908908
if (!pngFilename.isEmpty() && !pngFilename.isNull()) {
909909
// Save the current frame as a PNG
910-
qDebug() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Saving current frame as" << pngFilename;
910+
tbcDebugStream() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Saving current frame as" << pngFilename;
911911

912912
// Generate QImage for the current frame
913913
QImage imageToSave = tbcSource.getImage();
@@ -922,7 +922,7 @@ void MainWindow::on_actionSave_frame_as_PNG_triggered()
922922

923923
// Save the QImage as PNG
924924
if (!imageToSave.save(pngFilename)) {
925-
qDebug() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Failed to save file as" << pngFilename;
925+
tbcDebugStream() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Failed to save file as" << pngFilename;
926926

927927
QMessageBox messageBox;
928928
messageBox.warning(this, tr("Warning"),tr("Could not save a PNG using the specified filename!"));
@@ -931,7 +931,7 @@ void MainWindow::on_actionSave_frame_as_PNG_triggered()
931931
// Update the configuration for the PNG directory
932932
QFileInfo pngFileInfo(pngFilename);
933933
configuration.setPngDirectory(pngFileInfo.absolutePath());
934-
qDebug() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Setting PNG directory to:" << pngFileInfo.absolutePath();
934+
tbcDebugStream() << "MainWindow::on_actionSave_frame_as_PNG_triggered(): Setting PNG directory to:" << pngFileInfo.absolutePath();
935935
configuration.writeConfiguration();
936936
}
937937
}
@@ -1393,14 +1393,14 @@ void MainWindow::on_viewPushButton_clicked()
13931393
{
13941394
switch (tbcSource.getViewMode()) {
13951395
case TbcSource::ViewMode::FRAME_VIEW:
1396-
qDebug() << "Changing to SPLIT_VIEW mode";
1396+
tbcDebugStream() << "Changing to SPLIT_VIEW mode";
13971397

13981398
// Set split mode
13991399
tbcSource.setViewMode(TbcSource::ViewMode::SPLIT_VIEW);
14001400
break;
14011401

14021402
case TbcSource::ViewMode::SPLIT_VIEW:
1403-
qDebug() << "Changing to FIELD_VIEW mode (1:1)";
1403+
tbcDebugStream() << "Changing to FIELD_VIEW mode (1:1)";
14041404

14051405
// Set field mode with 1:1 aspect
14061406
tbcSource.setViewMode(TbcSource::ViewMode::FIELD_VIEW);
@@ -1409,12 +1409,12 @@ void MainWindow::on_viewPushButton_clicked()
14091409

14101410
case TbcSource::ViewMode::FIELD_VIEW:
14111411
if (!tbcSource.getStretchField()) {
1412-
qDebug() << "Changing to FIELD_VIEW mode (2:1)";
1412+
tbcDebugStream() << "Changing to FIELD_VIEW mode (2:1)";
14131413

14141414
// Set field mode with 2:1 aspect
14151415
tbcSource.setStretchField(true);
14161416
} else {
1417-
qDebug() << "Changing to FRAME_VIEW mode";
1417+
tbcDebugStream() << "Changing to FRAME_VIEW mode";
14181418

14191419
// Set frame mode
14201420
tbcSource.setViewMode(TbcSource::ViewMode::FRAME_VIEW);
@@ -1537,7 +1537,7 @@ void MainWindow::on_mouseModePushButton_clicked()
15371537
// Handler called when another class changes the currently selected scan line
15381538
void MainWindow::scopeCoordsChangedSignalHandler(qint32 xCoord, qint32 yCoord)
15391539
{
1540-
qDebug() << "MainWindow::scanLineChangedSignalHandler(): Called with xCoord =" << xCoord << "and yCoord =" << yCoord;
1540+
tbcDebugStream() << "MainWindow::scanLineChangedSignalHandler(): Called with xCoord =" << xCoord << "and yCoord =" << yCoord;
15411541

15421542
if (tbcSource.getIsSourceLoaded()) {
15431543
// Show the oscilloscope dialogue for the selected scan-line
@@ -1554,7 +1554,7 @@ void MainWindow::scopeCoordsChangedSignalHandler(qint32 xCoord, qint32 yCoord)
15541554
// Handler called when vectorscope settings are changed
15551555
void MainWindow::vectorscopeChangedSignalHandler()
15561556
{
1557-
qDebug() << "MainWindow::vectorscopeChangedSignalHandler(): Called";
1557+
tbcDebugStream() << "MainWindow::vectorscopeChangedSignalHandler(): Called";
15581558

15591559
if (tbcSource.getIsSourceLoaded()) {
15601560
// Update the vectorscope
@@ -1684,7 +1684,7 @@ void MainWindow::chromaDecoderConfigChangedSignalHandler()
16841684
// Signal handler for busy signal from TbcSource class
16851685
void MainWindow::on_busy(QString infoMessage)
16861686
{
1687-
qDebug() << "MainWindow::on_busy(): Got signal with message" << infoMessage;
1687+
tbcDebugStream() << "MainWindow::on_busy(): Got signal with message" << infoMessage;
16881688
// Set the busy message and centre the dialog in the parent window
16891689
busyDialog->setMessage(infoMessage);
16901690
busyDialog->move(this->geometry().center() - busyDialog->rect().center());
@@ -1701,7 +1701,7 @@ void MainWindow::on_busy(QString infoMessage)
17011701
// Signal handler for finishedLoading signal from TbcSource class
17021702
void MainWindow::on_finishedLoading(bool success)
17031703
{
1704-
qDebug() << "MainWindow::on_finishedLoading(): Called";
1704+
tbcDebugStream() << "MainWindow::on_finishedLoading(): Called";
17051705

17061706
// Hide the busy dialogue
17071707
busyDialog->hide();
@@ -1741,7 +1741,7 @@ void MainWindow::on_finishedLoading(bool success)
17411741
// Update the configuration for the source directory
17421742
QFileInfo inFileInfo(tbcSource.getCurrentSourceFilename());
17431743
configuration.setSourceDirectory(inFileInfo.absolutePath());
1744-
qDebug() << "MainWindow::loadTbcFile(): Setting source directory to:" << inFileInfo.absolutePath();
1744+
tbcDebugStream() << "MainWindow::loadTbcFile(): Setting source directory to:" << inFileInfo.absolutePath();
17451745
configuration.writeConfiguration();
17461746
} else {
17471747
// Load failed
@@ -1759,7 +1759,7 @@ void MainWindow::on_finishedLoading(bool success)
17591759
// Signal handler for finishedSaving signal from TbcSource class
17601760
void MainWindow::on_finishedSaving(bool success)
17611761
{
1762-
qDebug() << "MainWindow::on_finishedSaving(): Called";
1762+
tbcDebugStream() << "MainWindow::on_finishedSaving(): Called";
17631763

17641764
// Hide the busy dialogue
17651765
busyDialog->hide();

tools/ld-analyse/oscilloscopedialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "oscilloscopedialog.h"
1212
#include "ui_oscilloscopedialog.h"
13+
#include "logging.h"
1314

1415
#include <cassert>
1516

@@ -49,7 +50,7 @@ OscilloscopeDialog::~OscilloscopeDialog()
4950

5051
void OscilloscopeDialog::showTraceImage(TbcSource::ScanLineData scanLineData, qint32 xCoord, qint32 yCoord, qint32 frameWidth, qint32 frameHeight, bool bothSources)
5152
{
52-
qDebug() << "OscilloscopeDialog::showTraceImage(): Called with xCoord =" << xCoord << "and yCoord =" << yCoord;
53+
tbcDebugStream() << "OscilloscopeDialog::showTraceImage(): Called with xCoord =" << xCoord << "and yCoord =" << yCoord;
5354

5455
// Store coordinates
5556
maximumX = frameWidth;

0 commit comments

Comments
 (0)