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

Side by Side Diff: pkg/analysis_server/lib/src/analysis_logger.dart

Issue 840553004: Capture log messages via instrumentation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/lib/instrumentation/file_instrumentation.dart » ('j') | 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 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() {
22 logging.Logger.root.onRecord.listen((logging.LogRecord record) {
23 AnalysisEngine.instance.instrumentationService.logLogEntry(
24 record.level.name,
25 record.time,
26 record.message);
27 });
28 }
29
21 @override 30 @override
22 void logError(String message, [CaughtException exception]) { 31 void logError(String message, [CaughtException exception]) {
23 if (exception == null) { 32 if (exception == null) {
24 baseLogger.severe(message); 33 baseLogger.severe(message);
25 } else { 34 } else {
26 baseLogger.severe(message, exception.exception, exception.stackTrace); 35 baseLogger.severe(message, exception.exception, exception.stackTrace);
27 } 36 }
28 } 37 }
29 38
30 @override 39 @override
31 void logError2(String message, Object exception) { 40 void logError2(String message, Object exception) {
32 baseLogger.severe(message, exception); 41 baseLogger.severe(message, exception);
33 } 42 }
34 43
35 @override 44 @override
36 void logInformation(String message, [CaughtException exception]) { 45 void logInformation(String message, [CaughtException exception]) {
37 if (exception == null) { 46 if (exception == null) {
38 baseLogger.info(message); 47 baseLogger.info(message);
39 } else { 48 } else {
40 baseLogger.info(message, exception.exception, exception.stackTrace); 49 baseLogger.info(message, exception.exception, exception.stackTrace);
41 } 50 }
42 } 51 }
43 52
44 @override 53 @override
45 void logInformation2(String message, Object exception) { 54 void logInformation2(String message, Object exception) {
46 baseLogger.info(message, exception); 55 baseLogger.info(message, exception);
47 } 56 }
48 } 57 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/instrumentation/file_instrumentation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698