summaryrefslogtreecommitdiff
path: root/src/qcam/message_handler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qcam/message_handler.cpp')
-rw-r--r--src/qcam/message_handler.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qcam/message_handler.cpp b/src/qcam/message_handler.cpp
new file mode 100644
index 00000000..261623e1
--- /dev/null
+++ b/src/qcam/message_handler.cpp
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2020, Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * message_handler.cpp - qcam - Log message handling
+ */
+
+#include "message_handler.h"
+
+QtMessageHandler MessageHandler::handler_ = nullptr;
+bool MessageHandler::verbose_ = false;
+
+MessageHandler::MessageHandler(bool verbose)
+{
+ verbose_ = verbose;
+ handler_ = qInstallMessageHandler(&MessageHandler::handleMessage);
+}
+
+void MessageHandler::handleMessage(QtMsgType type,
+ const QMessageLogContext &context,
+ const QString &msg)
+{
+ if (type == QtDebugMsg && !verbose_)
+ return;
+
+ handler_(type, context, msg);
+}