Merge lp:~michael-sheldon/ubuntu-download-manager/fix-1461444 into lp:ubuntu-download-manager

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 351
Merged at revision: 353
Proposed branch: lp:~michael-sheldon/ubuntu-download-manager/fix-1461444
Merge into: lp:ubuntu-download-manager
Diff against target: 35 lines (+13/-0)
1 file modified
src/common/public/ubuntu/transfers/system/logger.cpp (+13/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-download-manager/fix-1461444
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+289367@code.launchpad.net

Commit message

Clean up old log files

Description of the change

Clean up old log files

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/common/public/ubuntu/transfers/system/logger.cpp'
2--- src/common/public/ubuntu/transfers/system/logger.cpp 2014-07-21 12:30:56 +0000
3+++ src/common/public/ubuntu/transfers/system/logger.cpp 2016-03-17 14:04:15 +0000
4@@ -105,18 +105,31 @@
5 void
6 Logger::setupLogging(const QString logDir) {
7 auto path = logDir;
8+ QDir *dir;
9 if (path == "" ){
10 path = getLogDir() + QDir::separator() + LOG_NAME;
11+ dir = new QDir(getLogDir());
12 } else {
13 bool wasCreated = QDir().mkpath(logDir);
14 if (wasCreated) {
15 path = QDir(logDir).absoluteFilePath(LOG_NAME);
16+ dir = new QDir(logDir);
17 } else {
18 qCritical() << "Could not create the logging path" << logDir;
19 path = getLogDir() + QDir::separator() + LOG_NAME;
20+ dir = new QDir(getLogDir());
21 }
22 }
23
24+ // Only keep the last 100 most recent logs
25+ QStringList nameFilter;
26+ nameFilter << LOG_NAME + "*";
27+ QStringList logFiles = dir->entryList(nameFilter, QDir::Files | QDir::Hidden | QDir::Writable, QDir::Time);
28+ for (int i = 99; i < logFiles.count(); i++) {
29+ QFile logFile(dir->absoluteFilePath(logFiles[i]));
30+ logFile.remove();
31+ }
32+
33 auto appName = QCoreApplication::instance()->applicationName();
34
35 if (!_init) {

Subscribers

People subscribed via source and target branches