Skip to content

Commit 2372126

Browse files
committed
Gate OSC debug logging behind --verbose flag
OSC message logging on every received message was slowing things down. Now only printed when running with -V/--verbose. Off by default.
1 parent bb5708b commit 2372126

5 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/app/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ int main(int argc, char *argv[])
110110
"Use language <lang>.", "lang", "");
111111
parser.addOption(localeOption);
112112

113+
// --verbose option
114+
QCommandLineOption verboseOption(QStringList() << "V" << "verbose",
115+
"Enable verbose output, including OSC message logging.");
116+
parser.addOption(verboseOption);
117+
113118
// --frame-rate option
114119
QCommandLineOption frameRateOption(QStringList() << "r" << "frame-rate",
115120
"Use a framerate of <frame-rate> per second.", "frame-rate", QString::number(MM::DEFAULT_FRAMES_PER_SECOND));
@@ -205,6 +210,9 @@ int main(int argc, char *argv[])
205210
if (oscPortValue != "")
206211
win->setOscPort(oscPortValue);
207212

213+
if (parser.isSet(verboseOption))
214+
win->setVerbose(true);
215+
208216
bool optionOk;
209217
qreal fps = parser.value("frame-rate").toDouble(&optionOk);
210218
if (optionOk)

src/control/OscInterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ static void printCommand(QVariantList &command)
148148

149149
void OscInterface::applyOscCommand(MainWindow &main_window, QVariantList & command) {
150150
Q_UNUSED(main_window);
151-
bool VERBOSE = false;
152151

153-
if (VERBOSE)
152+
if (is_verbose())
154153
{
155154
std::cout << "OscInterface::applyOscCommand: Receive OSC: " << std::endl;
156155
printCommand(command);
@@ -211,7 +210,8 @@ void OscInterface::applyOscCommand(MainWindow &main_window, QVariantList & comma
211210
}
212211
// Property setting (eg. opacity)
213212
else if (command.size() >= 4) {
214-
qDebug() << "Attempt to set a source property" << iterator.first << command.at(3);
213+
if (is_verbose())
214+
qDebug() << "Attempt to set a source property" << iterator.first << command.at(3);
215215
pathIsValid |= setElementProperty(elem, iterator.first, command.at(3));
216216
}
217217
}
@@ -266,7 +266,7 @@ void OscInterface::applyOscCommand(MainWindow &main_window, QVariantList & comma
266266
}
267267
}
268268

269-
if (! pathIsValid)
269+
if (! pathIsValid && is_verbose())
270270
{
271271
qDebug() << "Path could not be processed: " << path << Qt::endl;
272272
printCommand(command);

src/control/OscInterface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class OscInterface {
4545
OscInterface(int listen_port);
4646
~OscInterface();
4747

48+
void setVerbose(bool verbose) { verbose_ = verbose; }
49+
4850
/// Starts listening if receiving is enabled.
4951
void start();
5052

@@ -59,9 +61,10 @@ class OscInterface {
5961
// FIXME use QObject signals instead of polling
6062

6163
private:
62-
bool is_verbose() const { return false; }
64+
bool is_verbose() const { return verbose_; }
6365
void push_command(QVariantList command);
6466

67+
bool verbose_ = false;
6568
bool receiving_enabled_;
6669
OscReceiver receiver_;
6770
ConcurrentQueue<QVariantList> messaging_queue_;

src/gui/MainWindow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,6 +3714,12 @@ int MainWindow::getOscPort() const
37143714
return oscListeningPort;
37153715
}
37163716

3717+
void MainWindow::setVerbose(bool verbose)
3718+
{
3719+
if (osc_interface)
3720+
osc_interface->setVerbose(verbose);
3721+
}
3722+
37173723
bool MainWindow::setOscPort(QString portNumber)
37183724
{
37193725
bool ok;

src/gui/MainWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ public slots:
623623
bool setOscPort(QString portNumber);
624624
bool setOscPort(int portNumber);
625625
int getOscPort() const;
626+
void setVerbose(bool verbose);
626627
void setOutputWindowFullScreen(bool enable);
627628

628629
public:

0 commit comments

Comments
 (0)