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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library driver; 5 library driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:math'; 9 import 'dart:math';
10 10
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } else { 376 } else {
377 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, 377 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk,
378 // which will make a guess. 378 // which will make a guess.
379 defaultSdk = DirectoryBasedDartSdk.defaultSdk; 379 defaultSdk = DirectoryBasedDartSdk.defaultSdk;
380 } 380 }
381 // 381 //
382 // Initialize the instrumentation service. 382 // Initialize the instrumentation service.
383 // 383 //
384 String logFilePath = results[INSTRUMENTATION_LOG_FILE]; 384 String logFilePath = results[INSTRUMENTATION_LOG_FILE];
385 if (logFilePath != null) { 385 if (logFilePath != null) {
386 _rollLogFiles(logFilePath, 5);
386 FileInstrumentationServer fileBasedServer = 387 FileInstrumentationServer fileBasedServer =
387 new FileInstrumentationServer(logFilePath); 388 new FileInstrumentationServer(logFilePath);
388 instrumentationServer = instrumentationServer != null 389 instrumentationServer = instrumentationServer != null
389 ? new MulticastInstrumentationServer( 390 ? new MulticastInstrumentationServer(
390 [instrumentationServer, fileBasedServer]) 391 [instrumentationServer, fileBasedServer])
391 : fileBasedServer; 392 : fileBasedServer;
392 } 393 }
393 InstrumentationService service = 394 InstrumentationService service =
394 new InstrumentationService(instrumentationServer); 395 new InstrumentationService(instrumentationServer);
395 service.logVersion(_readUuid(service), results[CLIENT_ID], 396 service.logVersion(_readUuid(service), results[CLIENT_ID],
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 try { 571 try {
571 uuidFile.parent.createSync(recursive: true); 572 uuidFile.parent.createSync(recursive: true);
572 uuidFile.writeAsStringSync(uuid); 573 uuidFile.writeAsStringSync(uuid);
573 } catch (exception, stackTrace) { 574 } catch (exception, stackTrace) {
574 service.logPriorityException(exception, stackTrace); 575 service.logPriorityException(exception, stackTrace);
575 // Slightly alter the uuid to indicate it was not persisted 576 // Slightly alter the uuid to indicate it was not persisted
576 uuid = 'temp-$uuid'; 577 uuid = 'temp-$uuid';
577 } 578 }
578 return uuid; 579 return uuid;
579 } 580 }
581
582 /**
583 * Perform log files rolling.
584 *
585 * Rename existing files with names `[path].(x)` to `[path].(x+1)`.
586 * Keep at most [numOld] files.
587 * Rename the file with the given [path] to `[path].1`.
588 */
589 static void _rollLogFiles(String path, int numOld) {
590 for (int i = numOld - 1; i >= 0; i--) {
591 try {
592 String oldPath = i == 0 ? path : '$path.$i';
593 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
594 } catch (e) {}
595 }
596 }
580 } 597 }
OLDNEW
« 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