MCPcopy Create free account
hub / github.com/KikoPlayProject/KikoPlay / refreshLogFile

Method refreshLogFile

Common/logger.cpp:106–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void Logger::refreshLogFile()
107{
108 QDir folder;
109 if(!folder.exists(logFolder))
110 folder.mkpath(logFolder);
111 folder.setPath(logFolder);
112
113 QRegularExpression re("\\d{4}-\\d{2}-\\d{2}");
114 qint64 curTime = QDateTime::currentDateTime().toSecsSinceEpoch();
115 for (QFileInfo fileInfo : folder.entryInfoList())
116 {
117 if (fileInfo.isFile() && fileInfo.suffix().toLower()=="log")
118 {
119 auto match = re.match(fileInfo.fileName());
120 if (!match.hasMatch() || match.capturedStart(0) != 0) continue;
121 //if(re.indexIn(fileInfo.fileName())!=0) continue;
122 int logTime = QDateTime::fromString(match.captured(0), "yyyy-MM-dd").toSecsSinceEpoch();
123 if(curTime - logTime > 3*24*3600)
124 {
125 folder.remove(fileInfo.fileName());
126 log(LogType::APP, QString("Remove Log File: %1").arg(fileInfo.fileName()));
127 }
128 }
129 }
130}
131
132void Logger::writeLogFile(Logger::LogType type)
133{

Callers

nothing calls this directly

Calls 6

QStringClass · 0.85
existsMethod · 0.80
mkpathMethod · 0.80
setPathMethod · 0.80
matchMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected