Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3108)

Unified Diff: pkg/analysis_server/lib/src/server/driver.dart

Issue 1418143006: Roll instrumentation log files. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/server/driver.dart
diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart
index 049037742b98d4a0a6709e0073ac8ce41a0268c5..845a2618dc90c2301a77b0ee6b4625b5c08af995 100644
--- a/pkg/analysis_server/lib/src/server/driver.dart
+++ b/pkg/analysis_server/lib/src/server/driver.dart
@@ -383,6 +383,7 @@ class Driver implements ServerStarter {
//
String logFilePath = results[INSTRUMENTATION_LOG_FILE];
if (logFilePath != null) {
+ _rollLogFiles(logFilePath, 5);
FileInstrumentationServer fileBasedServer =
new FileInstrumentationServer(logFilePath);
instrumentationServer = instrumentationServer != null
@@ -577,4 +578,20 @@ class Driver implements ServerStarter {
}
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}');
Brian Wilkerson 2015/11/04 23:00:29 Does rename work if there's already a file with th
scheglov 2015/11/05 16:40:27 Yes, it does. /** * Synchronously renames t
+ } catch (e) {}
+ }
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698