OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 csslib.src.messages; | 5 library csslib.src.messages; |
6 | 6 |
7 import 'package:logging/logging.dart' show Level; | 7 import 'package:logging/logging.dart' show Level; |
8 import 'package:source_span/source_span.dart'; | 8 import 'package:source_span/source_span.dart'; |
9 | 9 |
10 import 'options.dart'; | 10 import 'options.dart'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 Message(this.level, this.message, {SourceSpan span, bool useColors: false}) | 49 Message(this.level, this.message, {SourceSpan span, bool useColors: false}) |
50 : this.span = span, | 50 : this.span = span, |
51 this.useColors = useColors; | 51 this.useColors = useColors; |
52 | 52 |
53 String toString() { | 53 String toString() { |
54 var output = new StringBuffer(); | 54 var output = new StringBuffer(); |
55 bool colors = useColors && _ERROR_COLORS.containsKey(level); | 55 bool colors = useColors && _ERROR_COLORS.containsKey(level); |
56 var levelColor = colors ? _ERROR_COLORS[level] : null; | 56 var levelColor = colors ? _ERROR_COLORS[level] : null; |
57 if (colors) output.write(levelColor); | 57 if (colors) output.write(levelColor); |
58 output | 58 output..write(_ERROR_LABEL[level])..write(' '); |
59 ..write(_ERROR_LABEL[level]) | |
60 ..write(' '); | |
61 if (colors) output.write(NO_COLOR); | 59 if (colors) output.write(NO_COLOR); |
62 | 60 |
63 if (span == null) { | 61 if (span == null) { |
64 output.write(message); | 62 output.write(message); |
65 } else { | 63 } else { |
66 output.write('on '); | 64 output.write('on '); |
67 output.write(span.message(message, color: levelColor)); | 65 output.write(span.message(message, color: levelColor)); |
68 } | 66 } |
69 | 67 |
70 return output.toString(); | 68 return output.toString(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 119 } |
122 | 120 |
123 /** Merge [newMessages] to this message lsit. */ | 121 /** Merge [newMessages] to this message lsit. */ |
124 void mergeMessages(Messages newMessages) { | 122 void mergeMessages(Messages newMessages) { |
125 messages.addAll(newMessages.messages); | 123 messages.addAll(newMessages.messages); |
126 newMessages.messages | 124 newMessages.messages |
127 .where((message) => message.level == Level.SEVERE || options.verbose) | 125 .where((message) => message.level == Level.SEVERE || options.verbose) |
128 .forEach(printHandler); | 126 .forEach(printHandler); |
129 } | 127 } |
130 } | 128 } |
OLD | NEW |