Index: lib/logging.dart |
diff --git a/lib/logging.dart b/lib/logging.dart |
index 7654885721b1bf3c86dd7ff054b7f9f560313341..70c776b2f8bc610a03e0464f40e8b872f1c277aa 100644 |
--- a/lib/logging.dart |
+++ b/lib/logging.dart |
@@ -16,6 +16,12 @@ import 'dart:collection'; |
bool hierarchicalLoggingEnabled = false; |
/** |
+ * Automatically record stack traces for any message of this level or above. |
+ * Because this is expensive, this is off by default. |
+ */ |
+Level recordStackTraceAtLevel = Level.OFF; |
+ |
+/** |
* Level for the root-logger. This will be the level of all loggers if |
* [hierarchicalLoggingEnabled] is false. |
*/ |
@@ -147,11 +153,15 @@ class Logger { |
void log(Level logLevel, message, |
[Object error, StackTrace stackTrace, Zone zone]) { |
if (isLoggable(logLevel)) { |
- // If message is a Function, evaluate it. |
if (message is Function) message = message(); |
- // If message is still not a String, call toString(). |
if (message is! String) message = message.toString(); |
- // Only record the current zone if it was not given. |
+ if (stackTrace == null && logLevel >= recordStackTraceAtLevel) { |
+ try { |
+ throw "log stack trace"; |
Jennifer Messerly
2015/05/07 22:32:19
include message here? e.g.
throw "log ${logLe
Siggi Cherem (dart-lang)
2015/05/08 00:31:03
Good point. Done.
|
+ } catch (e, t) { |
+ stackTrace = t; |
+ } |
+ } |
if (zone == null) zone = Zone.current; |
var record = |