Implement file logger.

This commit is contained in:
sledgehammer999
2016-01-25 01:06:06 +02:00
parent 0619aacf1f
commit faffefc4ff
10 changed files with 566 additions and 6 deletions

View File

@@ -58,6 +58,7 @@
#endif
#include "application.h"
#include "filelogger.h"
#include "base/logger.h"
#include "base/preferences.h"
#include "base/utils/fs.h"
@@ -103,10 +104,22 @@ Application::Application(const QString &id, int &argc, char **argv)
connect(this, SIGNAL(messageReceived(const QString &)), SLOT(processMessage(const QString &)));
connect(this, SIGNAL(aboutToQuit()), SLOT(cleanup()));
connect(Preferences::instance(), SIGNAL(changed()), SLOT(configure()));
configure();
Logger::instance()->addMessage(tr("qBittorrent %1 started", "qBittorrent v3.2.0alpha started").arg(VERSION));
}
void Application::configure()
{
bool fileLogEnabled = Preferences::instance()->fileLogEnabled();
if (fileLogEnabled && !m_fileLogger)
m_fileLogger = new FileLogger;
else if (!fileLogEnabled)
delete m_fileLogger;
}
void Application::processMessage(const QString &message)
{
QStringList params = message.split(QLatin1String(PARAMS_SEPARATOR), QString::SkipEmptyParts);
@@ -466,6 +479,7 @@ void Application::cleanup()
#endif
Net::DownloadManager::freeInstance();
Preferences::freeInstance();
delete m_fileLogger;
Logger::freeInstance();
IconProvider::freeInstance();
#ifndef DISABLE_GUI