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) {} |
+ } |
+ } |
} |