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 | 5 |
6 library logging_test; | 6 library logging_test; |
7 | 7 |
8 import 'package:logging/logging.dart'; | 8 import 'package:logging/logging.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 'FINEST: 1', | 221 'FINEST: 1', |
222 'FINER: 2', | 222 'FINER: 2', |
223 'FINE: 3', | 223 'FINE: 3', |
224 'CONFIG: 4', | 224 'CONFIG: 4', |
225 'INFO: 5', | 225 'INFO: 5', |
226 'WARNING: 6', | 226 'WARNING: 6', |
227 'SEVERE: 7', | 227 'SEVERE: 7', |
228 'SHOUT: 8'])); | 228 'SHOUT: 8'])); |
229 }); | 229 }); |
230 | 230 |
| 231 test('logging methods store exception', () { |
| 232 root.level = Level.ALL; |
| 233 var rootMessages = []; |
| 234 root.onRecord.listen((r) { |
| 235 rootMessages.add('${r.level}: ${r.message} ${r.exception}'); |
| 236 }); |
| 237 |
| 238 root.finest('1'); |
| 239 root.finer('2'); |
| 240 root.fine('3'); |
| 241 root.config('4'); |
| 242 root.info('5'); |
| 243 root.warning('6'); |
| 244 root.severe('7'); |
| 245 root.shout('8'); |
| 246 root.finest('1', 'a'); |
| 247 root.finer('2', 'b'); |
| 248 root.fine('3', ['c']); |
| 249 root.config('4', 'd'); |
| 250 root.info('5', 'e'); |
| 251 root.warning('6', 'f'); |
| 252 root.severe('7', 'g'); |
| 253 root.shout('8', 'h'); |
| 254 |
| 255 expect(rootMessages, equals([ |
| 256 'FINEST: 1 null', |
| 257 'FINER: 2 null', |
| 258 'FINE: 3 null', |
| 259 'CONFIG: 4 null', |
| 260 'INFO: 5 null', |
| 261 'WARNING: 6 null', |
| 262 'SEVERE: 7 null', |
| 263 'SHOUT: 8 null', |
| 264 'FINEST: 1 a', |
| 265 'FINER: 2 b', |
| 266 'FINE: 3 [c]', |
| 267 'CONFIG: 4 d', |
| 268 'INFO: 5 e', |
| 269 'WARNING: 6 f', |
| 270 'SEVERE: 7 g', |
| 271 'SHOUT: 8 h'])); |
| 272 }); |
| 273 |
231 test('message logging - no hierarchy', () { | 274 test('message logging - no hierarchy', () { |
232 root.level = Level.WARNING; | 275 root.level = Level.WARNING; |
233 var rootMessages = []; | 276 var rootMessages = []; |
234 var aMessages = []; | 277 var aMessages = []; |
235 var cMessages = []; | 278 var cMessages = []; |
236 c.onRecord.listen((record) { | 279 c.onRecord.listen((record) { |
237 cMessages.add('${record.level}: ${record.message}'); | 280 cMessages.add('${record.level}: ${record.message}'); |
238 }); | 281 }); |
239 a.onRecord.listen((record) { | 282 a.onRecord.listen((record) { |
240 aMessages.add('${record.level}: ${record.message}'); | 283 aMessages.add('${record.level}: ${record.message}'); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 'SHOUT: 10'])); | 370 'SHOUT: 10'])); |
328 | 371 |
329 expect(cMessages, equals([ | 372 expect(cMessages, equals([ |
330 // 1 - 7 are lower in the hierarchy | 373 // 1 - 7 are lower in the hierarchy |
331 // 'FINE: 8' is not loggable | 374 // 'FINE: 8' is not loggable |
332 'WARNING: 9', | 375 'WARNING: 9', |
333 'SHOUT: 10'])); | 376 'SHOUT: 10'])); |
334 }); | 377 }); |
335 }); | 378 }); |
336 } | 379 } |
OLD | NEW |