The csync log level was only set up on startup, and for log files.
Fix the issue by making Logger::isNoop rely on being explicitly activated
for the log window instead of relying on the presence of a connected
signal, and move the csync log level logic in Logger.
}
}
-static void csyncLogCatcher(int /*verbosity*/,
- const char */*function*/,
- const char *buffer,
- void */*userdata*/)
-{
- Logger::instance()->csyncLog( QString::fromUtf8(buffer) );
-}
-
void Application::setupLogging()
{
// might be called from second instance
.arg(property("ui_lang").toString())
.arg(_theme->version())
.arg(Utility::platformName());
-
- // Setup CSYNC logging to forward to our own logger
- csync_set_log_callback( csyncLogCatcher );
- csync_set_log_level( Logger::instance()->isNoop() ? 0 : 11 );
}
void Application::slotUseMonoIconsChanged(bool)
setModal(false);
+ Logger::instance()->setLogWindowActivated(true);
// Direct connection for log coming from this thread, and queued for the one in a different thread
- connect(Logger::instance(), SIGNAL(newLog(QString)),this,SLOT(slotNewLog(QString)), Qt::AutoConnection);
+ connect(Logger::instance(), SIGNAL(logWindowLog(QString)),this,SLOT(slotNewLog(QString)), Qt::AutoConnection);
QAction *showLogWindow = new QAction(this);
showLogWindow->setShortcut(QKeySequence("F12"));
#include <QThread>
#include <qmetaobject.h>
+#include "csync.h"
+
namespace OCC {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
}
#endif
+static void csyncLogCatcher(int /*verbosity*/,
+ const char * /*function*/,
+ const char *buffer,
+ void * /*userdata*/)
+{
+ Logger::instance()->csyncLog( QString::fromUtf8(buffer) );
+}
+
Logger *Logger::instance()
{
static Logger log;
}
Logger::Logger( QObject* parent) : QObject(parent),
- _showTime(true), _doLogging(false), _doFileFlush(false), _logExpire(0)
+ _showTime(true), _logWindowActivated(false), _doFileFlush(false), _logExpire(0)
{
#ifndef NO_MSG_HANDLER
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
#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;
+ return !_logstream && !_logWindowActivated;
#endif
}
if( _doFileFlush ) _logstream->flush();
}
}
- emit newLog(msg);
+ emit logWindowLog(msg);
}
void Logger::csyncLog( const QString& message )
Logger::instance()->log( log_ );
}
+void Logger::setLogWindowActivated(bool activated)
+{
+ QMutexLocker locker(&_mutex);
+
+ // Setup CSYNC logging to forward to our own logger
+ csync_set_log_callback(csyncLogCatcher);
+ csync_set_log_level(11);
+
+ _logWindowActivated = activated;
+}
+
void Logger::setLogFile(const QString & name)
{
QMutexLocker locker(&_mutex);
+ // Setup CSYNC logging to forward to our own logger
+ csync_set_log_callback(csyncLogCatcher);
+ csync_set_log_level(11);
+
if( _logstream ) {
_logstream.reset(0);
_logFile.close();
void postOptionalGuiLog(const QString& title, const QString& message);
void postGuiMessage(const QString& title, const QString& message);
+ void setLogWindowActivated(bool activated);
void setLogFile( const QString & name );
void setLogExpire( int expire );
void setLogDir( const QString& dir );
void setLogFlush( bool flush );
signals:
- void newLog(const QString&);
+ void logWindowLog(const QString&);
+
void guiLog(const QString&, const QString&);
void guiMessage(const QString&, const QString&);
void optionalGuiLog(const QString&, const QString&);
~Logger();
QList<Log> _logs;
bool _showTime;
- bool _doLogging;
+ bool _logWindowActivated;
QFile _logFile;
bool _doFileFlush;
int _logExpire;