Skip to content

Commit

Permalink
Merge pull request #430 from happycube/issue-427
Browse files Browse the repository at this point in the history
Fix for issue #427
  • Loading branch information
Simon Inns authored Jan 25, 2020
2 parents 95974f6 + ac9b9c7 commit 050a36b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
12 changes: 3 additions & 9 deletions tools/ld-chroma-decoder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
#include "paldecoder.h"
#include "transformpal.h"

// Global for quiet mode (suppress info and warning messages)
static bool showOutput = true;

// Load the thresholds file for the Transform decoders, if specified. We must
// do this after PalColour has been configured, so we know how many values to
// expect.
Expand Down Expand Up @@ -227,9 +224,9 @@ int main(int argc, char *argv[])
// Process the command line options and arguments given by the user
parser.process(a);

// Get the options from the parser
bool isDebugOn = parser.isSet(showDebugOption);
if (parser.isSet(setQuietOption)) showOutput = false;
// Get the debug options from the parser
if (parser.isSet(showDebugOption)) setDebug(true); else setDebug(false);
if (parser.isSet(setQuietOption)) setQuiet(true); else setQuiet(false);

// Get the arguments from the parser
QString inputFileName;
Expand Down Expand Up @@ -345,9 +342,6 @@ int main(int argc, char *argv[])
palConfig.showFFTs = true;
}

// Process the command line options
if (isDebugOn) setDebug(true); else setDebug(false);

// Work out the metadata filename
QString inputJsonFileName = inputFileName + ".json";
if (parser.isSet(inputJsonOption)) {
Expand Down
5 changes: 1 addition & 4 deletions tools/ld-export-metadata/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
#include "logging.h"
#include "lddecodemetadata.h"

// Global for quiet mode (suppress info and warning messages)
static bool showOutput = true;

int main(int argc, char *argv[])
{
// Install the local debug message handler
Expand Down Expand Up @@ -98,7 +95,7 @@ int main(int argc, char *argv[])

// Get the options from the parser
if (parser.isSet(showDebugOption)) setDebug(true); else setDebug(false);
if (parser.isSet(setQuietOption)) showOutput = false;
if (parser.isSet(setQuietOption)) setQuiet(true); else setQuiet(false);

// Get the arguments from the parser
QString inputFileName;
Expand Down
14 changes: 12 additions & 2 deletions tools/library/tbc/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// Global for debug output
static bool showDebug = false;
static bool saveDebug = false;
static bool quietDebug = false;
static QFile *debugFile;

// Qt debug message handler
Expand Down Expand Up @@ -64,8 +65,11 @@ void debugOutputHandler(QtMsgType type, const QMessageLogContext &context, const
break;
}

// Display the output message on stderr
if (showDebug || (type != QtDebugMsg)) QTextStream(stderr) << outputMessage;
// If quiet mode is set, suppress all output
if (!quietDebug) {
// Display the output message on stderr
if (showDebug || (type != QtDebugMsg)) QTextStream(stderr) << outputMessage;
}

// Optional output to file
if (saveDebug) QTextStream(debugFile) << outputMessage;
Expand Down Expand Up @@ -96,3 +100,9 @@ void setDebug(bool state)
{
showDebug = state;
}

// Control the quiet flag (if set all output is suppressed)
void setQuiet(bool state)
{
quietDebug = state;
}
1 change: 1 addition & 0 deletions tools/library/tbc/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
// Prototypes
void debugOutputHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
void setDebug(bool state);
void setQuiet(bool state);
void openDebugFile(QString filename);
void closeDebugFile(void);

Expand Down

0 comments on commit 050a36b

Please sign in to comment.