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

Side by Side Diff: lib/logging.dart

Issue 1284983004: Also generate error when autogenerating stack traces (fix #25) (Closed) Base URL: git@github.com:dart-lang/logging.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('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) 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 */ 6 */
7 library logging; 7 library logging;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void log(Level logLevel, message, 153 void log(Level logLevel, message,
154 [Object error, StackTrace stackTrace, Zone zone]) { 154 [Object error, StackTrace stackTrace, Zone zone]) {
155 if (isLoggable(logLevel)) { 155 if (isLoggable(logLevel)) {
156 if (message is Function) message = message(); 156 if (message is Function) message = message();
157 if (message is! String) message = message.toString(); 157 if (message is! String) message = message.toString();
158 if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { 158 if (stackTrace == null && logLevel >= recordStackTraceAtLevel) {
159 try { 159 try {
160 throw "autogenerated stack trace for $logLevel $message"; 160 throw "autogenerated stack trace for $logLevel $message";
161 } catch (e, t) { 161 } catch (e, t) {
162 stackTrace = t; 162 stackTrace = t;
163 if (error == null) error = e;
163 } 164 }
164 } 165 }
165 if (zone == null) zone = Zone.current; 166 if (zone == null) zone = Zone.current;
166 167
167 var record = 168 var record =
168 new LogRecord(logLevel, message, fullName, error, stackTrace, zone); 169 new LogRecord(logLevel, message, fullName, error, stackTrace, zone);
169 170
170 if (hierarchicalLoggingEnabled) { 171 if (hierarchicalLoggingEnabled) {
171 var target = this; 172 var target = this;
172 while (target != null) { 173 while (target != null) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 /** Zone of the calling code which resulted in this LogRecord. */ 343 /** Zone of the calling code which resulted in this LogRecord. */
343 final Zone zone; 344 final Zone zone;
344 345
345 LogRecord(this.level, this.message, this.loggerName, 346 LogRecord(this.level, this.message, this.loggerName,
346 [this.error, this.stackTrace, this.zone]) 347 [this.error, this.stackTrace, this.zone])
347 : time = new DateTime.now(), 348 : time = new DateTime.now(),
348 sequenceNumber = LogRecord._nextNumber++; 349 sequenceNumber = LogRecord._nextNumber++;
349 350
350 String toString() => '[${level.name}] $loggerName: $message'; 351 String toString() => '[${level.name}] $loggerName: $message';
351 } 352 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698