| 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 */ | 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |