summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-12-21 11:05:44 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-21 23:39:24 +0100
commit34a3fedf7b115c84ff305bf72fbc9d568682d84a (patch)
treec4d5ea2cbab786ada8ca4cfdf51ccddc32fd5568
parentc077c91e90bd3d221abb06c2bdafd31492243b93 (diff)
downloadMultiMC-34a3fedf7b115c84ff305bf72fbc9d568682d84a.tar
MultiMC-34a3fedf7b115c84ff305bf72fbc9d568682d84a.tar.gz
MultiMC-34a3fedf7b115c84ff305bf72fbc9d568682d84a.tar.lz
MultiMC-34a3fedf7b115c84ff305bf72fbc9d568682d84a.tar.xz
MultiMC-34a3fedf7b115c84ff305bf72fbc9d568682d84a.zip
Keep the last five logs
-rw-r--r--MultiMC.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp
index 71a8fe59..5d08af4c 100644
--- a/MultiMC.cpp
+++ b/MultiMC.cpp
@@ -280,12 +280,25 @@ void MultiMC::initTranslations()
}
}
+void moveFile(const QString &oldName, const QString &newName)
+{
+ QFile::remove(newName);
+ QFile::copy(oldName, newName);
+ QFile::remove(oldName);
+}
void MultiMC::initLogger()
{
+ static const QString logBase = "MultiMC-%0.log";
+
+ moveFile(logBase.arg(3), logBase.arg(4));
+ moveFile(logBase.arg(2), logBase.arg(3));
+ moveFile(logBase.arg(1), logBase.arg(2));
+ moveFile(logBase.arg(0), logBase.arg(1));
+
// init the logging mechanism
QsLogging::Logger &logger = QsLogging::Logger::instance();
logger.setLoggingLevel(QsLogging::TraceLevel);
- m_fileDestination = QsLogging::DestinationFactory::MakeFileDestination("MultiMC.log");
+ m_fileDestination = QsLogging::DestinationFactory::MakeFileDestination(logBase.arg(0));
m_debugDestination = QsLogging::DestinationFactory::MakeQDebugDestination();
logger.addDestination(m_fileDestination.get());
logger.addDestination(m_debugDestination.get());