#include <QDir>
#include <QStringList>
#include <QThread>
+#include <qmetaobject.h>
namespace OCC {
}
#else
static void mirallLogCatcher(QtMsgType type, const QMessageLogContext &ctx, const QString &message) {
- Logger::instance()->doLog( qFormatLogMessage(type, ctx, message) ) ;
+ auto logger = Logger::instance();
+ if (!logger->isNoop()) {
+ logger->doLog( qFormatLogMessage(type, ctx, message) ) ;
+ }
}
#endif
doLog(msg);
}
+/**
+ * Returns true if doLog does nothing and need not to be called
+ */
+bool Logger::isNoop() const
+{
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+ return false;
+#else
+ static auto signal = QMetaMethod::fromSignal(&Logger::newLog);
+ if (isSignalConnected(signal)) {
+ return false;
+ }
+ QMutexLocker lock(const_cast<QMutex *>(&_mutex));
+ return !_logstream;
+#endif
+}
+
+
void Logger::doLog(const QString& msg)
{
{