" --logexpire <hours> : removes logs older than <hours> hours.\n"
" (to be used with --logdir)\n"
" --logflush : flush the log file after every write.\n"
+ " --logdebug : also output debug-level messages in the log (equivalent to setting the env var QT_LOGGING_RULES=\"qt.*=true;*.debug=true\").\n"
" --confdir <dirname> : Use the given configuration folder.\n"
;
_showLogWindow(false),
_logExpire(0),
_logFlush(false),
+ _logDebug(false),
_userTriggeredConnect(false),
_debugMode(false)
{
Logger::instance()->setLogDir(_logDir);
Logger::instance()->setLogExpire(_logExpire);
Logger::instance()->setLogFlush(_logFlush);
+ Logger::instance()->setLogDebug(_logDebug);
Logger::instance()->enterNextLogFile();
}
} else if (option == QLatin1String("--logflush")) {
_logFlush = true;
+ } else if (option == QLatin1String("--logdebug")) {
+ _logDebug = true;
} else if (option == QLatin1String("--confdir")) {
if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) {
QString confDir = it.next();
QString _logDir;
int _logExpire;
bool _logFlush;
+ bool _logDebug;
bool _userTriggeredConnect;
bool _debugMode;
toolLayout->addWidget( _statusLabel );
toolLayout->addStretch(5);
+ // Debug logging
+ _logDebugCheckBox = new QCheckBox(tr("&Capture debug messages") + " ");
+ connect(_logDebugCheckBox, SIGNAL(stateChanged(int)), SLOT(slotDebugCheckStateChanged(int)));
+ toolLayout->addWidget( _logDebugCheckBox );
+
QDialogButtonBox *btnbox = new QDialogButtonBox;
QPushButton *closeBtn = btnbox->addButton( QDialogButtonBox::Close );
connect(closeBtn,SIGNAL(clicked()),this,SLOT(close()));
{
}
+void LogBrowser::showEvent(QShowEvent *)
+{
+ // This could have been changed through the --logdebug argument passed through the single application.
+ _logDebugCheckBox->setCheckState(Logger::instance()->logDebug() ? Qt::Checked : Qt::Unchecked);
+}
+
void LogBrowser::closeEvent(QCloseEvent *)
{
ConfigFile cfg;
search( searchText );
}
+void LogBrowser::slotDebugCheckStateChanged(int checkState)
+{
+ Logger::instance()->setLogDebug(checkState == Qt::Checked);
+}
+
void LogBrowser::search( const QString& str )
{
QList<QTextEdit::ExtraSelection> extraSelections;
#ifndef LOGBROWSER_H
#define LOGBROWSER_H
+#include <QCheckBox>
#include <QPlainTextEdit>
#include <QTextStream>
#include <QFile>
void setLogFile(const QString& , bool );
protected:
+ void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
void closeEvent(QCloseEvent *) Q_DECL_OVERRIDE;
protected slots:
void slotNewLog( const QString &msg );
void slotFind();
+ void slotDebugCheckStateChanged(int);
void search( const QString& );
void slotSave();
void slotClearLog();
private:
LogWidget *_logWidget;
QLineEdit *_findTermEdit;
+ QCheckBox *_logDebugCheckBox;
QPushButton *_saveBtn;
QPushButton *_clearBtn;
QLabel *_statusLabel;
}
Logger::Logger( QObject* parent) : QObject(parent),
- _showTime(true), _logWindowActivated(false), _doFileFlush(false), _logExpire(0)
+ _showTime(true), _logWindowActivated(false), _doFileFlush(false), _logExpire(0), _logDebug(false)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
qSetMessagePattern("%{time MM-dd hh:mm:ss:zzz} [ %{type} %{category} ]%{if-debug}\t[ %{function} ]%{endif}:\t%{message}");
_doFileFlush = flush;
}
+void Logger::setLogDebug( bool debug )
+{
+ QLoggingCategory::setFilterRules(debug ? QStringLiteral("qt.*=true\n*.debug=true") : QString());
+ _logDebug = debug;
+}
+
void Logger::enterNextLogFile()
{
if (!_logDirectory.isEmpty()) {
void setLogDir( const QString& dir );
void setLogFlush( bool flush );
+ bool logDebug() const { return _logDebug; }
+ void setLogDebug( bool debug );
+
signals:
void logWindowLog(const QString&);
QFile _logFile;
bool _doFileFlush;
int _logExpire;
+ bool _logDebug;
QScopedPointer<QTextStream> _logstream;
QMutex _mutex;
QString _logDirectory;