Implement file logger.

This commit is contained in:
sledgehammer999 2016-01-25 01:06:06 +02:00
parent 73832a5ed8
commit 1058572c8a
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/settingsstorage.h"
#include "base/preferences.h"
@ -105,10 +106,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);
@ -469,6 +482,7 @@ void Application::cleanup()
Net::DownloadManager::freeInstance();
Preferences::freeInstance();
SettingsStorage::freeInstance();
delete m_fileLogger;
Logger::freeInstance();
IconProvider::freeInstance();
#ifndef DISABLE_GUI