MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / openRotatingLog

Function openRotatingLog

TheForceEngine/TFE_System/log.cpp:165–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163 }
164
165 void openRotatingLog(const char* fileName, bool append)
166 {
167 if (!fileName) { return; }
168
169 char logPath[TFE_MAX_PATH];
170 TFE_Paths::appendPath(PATH_USER_DOCUMENTS, fileName, logPath);
171
172 // Handle rotations
173 for (int i = maxLogRotations; i > 0; i--)
174 {
175 char oldLogPath[TFE_MAX_PATH];
176 char newLogPath[TFE_MAX_PATH];
177 if (i == 1)
178 {
179 sprintf(oldLogPath, "%s", logPath);
180 }
181 else
182 {
183 sprintf(oldLogPath, "%s.%d", logPath, i - 1);
184 }
185
186 if (FileUtil::exists(oldLogPath))
187 {
188 sprintf(newLogPath, "%s.%d", logPath, i);
189 FileUtil::copyFile(oldLogPath, newLogPath);
190 }
191 }
192
193 // Open file as normal
194 logOpen(fileName, append);
195 }
196}
197

Callers 1

mainFunction · 0.85

Calls 4

logOpenFunction · 0.85
appendPathFunction · 0.50
existsFunction · 0.50
copyFileFunction · 0.50

Tested by

no test coverage detected