| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 * "file:/some/file/name" - log to the file, overwritten on start. | 39 * "file:/some/file/name" - log to the file, overwritten on start. |
| 40 */ | 40 */ |
| 41 void _initIncrementalLogger(String spec) { | 41 void _initIncrementalLogger(String spec) { |
| 42 logger = NULL_LOGGER; | 42 logger = NULL_LOGGER; |
| 43 if (spec == null) { | 43 if (spec == null) { |
| 44 return; | 44 return; |
| 45 } | 45 } |
| 46 // create logger | 46 // create logger |
| 47 if (spec == 'console') { | 47 if (spec == 'console') { |
| 48 logger = new StringSinkLogger(stdout); | 48 logger = new StringSinkLogger(stdout); |
| 49 } | 49 } else if (spec == 'stderr') { |
| 50 if (spec.startsWith('file:')) { | 50 logger = new StringSinkLogger(stderr); |
| 51 } else if (spec.startsWith('file:')) { |
| 51 String fileName = spec.substring('file:'.length); | 52 String fileName = spec.substring('file:'.length); |
| 52 File file = new File(fileName); | 53 File file = new File(fileName); |
| 53 IOSink sink = file.openWrite(); | 54 IOSink sink = file.openWrite(); |
| 54 logger = new StringSinkLogger(sink); | 55 logger = new StringSinkLogger(sink); |
| 55 } | 56 } |
| 56 } | 57 } |
| 57 | 58 |
| 58 /// Commandline argument parser. (Copied from analyzer/lib/options.dart) | 59 /// Commandline argument parser. (Copied from analyzer/lib/options.dart) |
| 59 /// TODO(pquitslund): replaces with a simple [ArgParser] instance | 60 /// TODO(pquitslund): replaces with a simple [ArgParser] instance |
| 60 /// when the args package supports ignoring unrecognized | 61 /// when the args package supports ignoring unrecognized |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 negatable: false); | 479 negatable: false); |
| 479 parser.addFlag(ENABLE_INSTRUMENTATION_OPTION, | 480 parser.addFlag(ENABLE_INSTRUMENTATION_OPTION, |
| 480 help: "enable sending instrumentation information to a server", | 481 help: "enable sending instrumentation information to a server", |
| 481 defaultsTo: false, | 482 defaultsTo: false, |
| 482 negatable: false); | 483 negatable: false); |
| 483 parser.addFlag(HELP_OPTION, | 484 parser.addFlag(HELP_OPTION, |
| 484 help: "print this help message without starting a server", | 485 help: "print this help message without starting a server", |
| 485 defaultsTo: false, | 486 defaultsTo: false, |
| 486 negatable: false); | 487 negatable: false); |
| 487 parser.addOption(INCREMENTAL_RESOLUTION_LOG, | 488 parser.addOption(INCREMENTAL_RESOLUTION_LOG, |
| 488 help: "the description of the incremental resolution log"); | 489 help: "set a destination for the incremental resolver's log"); |
| 489 parser.addFlag(INCREMENTAL_RESOLUTION_VALIDATION, | 490 parser.addFlag(INCREMENTAL_RESOLUTION_VALIDATION, |
| 490 help: "enable validation of incremental resolution results (slow)", | 491 help: "enable validation of incremental resolution results (slow)", |
| 491 defaultsTo: false, | 492 defaultsTo: false, |
| 492 negatable: false); | 493 negatable: false); |
| 493 parser.addOption(INSTRUMENTATION_LOG_FILE, | 494 parser.addOption(INSTRUMENTATION_LOG_FILE, |
| 494 help: | 495 help: |
| 495 "the path of the file to which instrumentation data will be written"
); | 496 "the path of the file to which instrumentation data will be written"
); |
| 496 parser.addFlag(INTERNAL_PRINT_TO_CONSOLE, | 497 parser.addFlag(INTERNAL_PRINT_TO_CONSOLE, |
| 497 help: "enable sending `print` output to the console", | 498 help: "enable sending `print` output to the console", |
| 498 defaultsTo: false, | 499 defaultsTo: false, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 */ | 579 */ |
| 579 static void _rollLogFiles(String path, int numOld) { | 580 static void _rollLogFiles(String path, int numOld) { |
| 580 for (int i = numOld - 1; i >= 0; i--) { | 581 for (int i = numOld - 1; i >= 0; i--) { |
| 581 try { | 582 try { |
| 582 String oldPath = i == 0 ? path : '$path.$i'; | 583 String oldPath = i == 0 ? path : '$path.$i'; |
| 583 new File(oldPath).renameSync('$path.${i+1}'); | 584 new File(oldPath).renameSync('$path.${i+1}'); |
| 584 } catch (e) {} | 585 } catch (e) {} |
| 585 } | 586 } |
| 586 } | 587 } |
| 587 } | 588 } |
| OLD | NEW |