mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:27:17 +00:00
Roll instrumentation log files.
Keep up to 5 old log files. R=brianwilkerson@google.com BUG= Review URL: https://codereview.chromium.org/1418143006 .
This commit is contained in:
parent
abcb3a4d4d
commit
61ee6dff5f
|
@ -383,6 +383,7 @@ class Driver implements ServerStarter {
|
||||||
//
|
//
|
||||||
String logFilePath = results[INSTRUMENTATION_LOG_FILE];
|
String logFilePath = results[INSTRUMENTATION_LOG_FILE];
|
||||||
if (logFilePath != null) {
|
if (logFilePath != null) {
|
||||||
|
_rollLogFiles(logFilePath, 5);
|
||||||
FileInstrumentationServer fileBasedServer =
|
FileInstrumentationServer fileBasedServer =
|
||||||
new FileInstrumentationServer(logFilePath);
|
new FileInstrumentationServer(logFilePath);
|
||||||
instrumentationServer = instrumentationServer != null
|
instrumentationServer = instrumentationServer != null
|
||||||
|
@ -577,4 +578,20 @@ class Driver implements ServerStarter {
|
||||||
}
|
}
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform log files rolling.
|
||||||
|
*
|
||||||
|
* Rename existing files with names `[path].(x)` to `[path].(x+1)`.
|
||||||
|
* Keep at most [numOld] files.
|
||||||
|
* Rename the file with the given [path] to `[path].1`.
|
||||||
|
*/
|
||||||
|
static void _rollLogFiles(String path, int numOld) {
|
||||||
|
for (int i = numOld - 1; i >= 0; i--) {
|
||||||
|
try {
|
||||||
|
String oldPath = i == 0 ? path : '$path.$i';
|
||||||
|
new File(oldPath).renameSync('$path.${i+1}');
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue