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 analysis.logger; | 5 library analysis.logger; |
6 | 6 |
7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
8 import 'package:analyzer/src/generated/java_engine.dart'; | 8 import 'package:analyzer/src/generated/java_engine.dart'; |
9 import 'package:logging/logging.dart' as logging; | 9 import 'package:logging/logging.dart' as logging; |
10 | 10 |
11 /** | 11 /** |
12 * Instances of the class [AnalysisLogger] translate from the analysis engine's | 12 * Instances of the class [AnalysisLogger] translate from the analysis engine's |
13 * API to the logging package's API. | 13 * API to the logging package's API. |
14 */ | 14 */ |
15 class AnalysisLogger implements Logger { | 15 class AnalysisLogger implements Logger { |
16 /** | 16 /** |
17 * The underlying logger that is being wrapped. | 17 * The underlying logger that is being wrapped. |
18 */ | 18 */ |
19 final logging.Logger baseLogger = new logging.Logger('analysis.server'); | 19 final logging.Logger baseLogger = new logging.Logger('analysis.server'); |
20 | 20 |
21 AnalysisLogger() { | 21 AnalysisLogger() { |
22 logging.Logger.root.onRecord.listen((logging.LogRecord record) { | 22 logging.Logger.root.onRecord.listen((logging.LogRecord record) { |
23 AnalysisEngine.instance.instrumentationService.logLogEntry( | 23 AnalysisEngine.instance.instrumentationService.logLogEntry( |
24 record.level.name, | 24 record.level.name, record.time, record.message); |
25 record.time, | |
26 record.message); | |
27 }); | 25 }); |
28 } | 26 } |
29 | 27 |
30 @override | 28 @override |
31 void logError(String message, [CaughtException exception]) { | 29 void logError(String message, [CaughtException exception]) { |
32 if (exception == null) { | 30 if (exception == null) { |
33 baseLogger.severe(message); | 31 baseLogger.severe(message); |
34 } else { | 32 } else { |
35 baseLogger.severe(message, exception.exception, exception.stackTrace); | 33 baseLogger.severe(message, exception.exception, exception.stackTrace); |
36 } | 34 } |
(...skipping 11 matching lines...) Expand all Loading... |
48 } else { | 46 } else { |
49 baseLogger.info(message, exception.exception, exception.stackTrace); | 47 baseLogger.info(message, exception.exception, exception.stackTrace); |
50 } | 48 } |
51 } | 49 } |
52 | 50 |
53 @override | 51 @override |
54 void logInformation2(String message, Object exception) { | 52 void logInformation2(String message, Object exception) { |
55 baseLogger.info(message, exception); | 53 baseLogger.info(message, exception); |
56 } | 54 } |
57 } | 55 } |
OLD | NEW |