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

Unified Diff: lib/logging.dart

Issue 786813002: Adding a "zone" value to "class LogRecord" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adding CHANGELOG.md updating pubspec.yaml 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/logging.dart
diff --git a/lib/logging.dart b/lib/logging.dart
index dc83d84899f9529508050411fe10212252ea273b..42344e83d2933a24dbe1b18605ae622ce117c4df 100644
--- a/lib/logging.dart
+++ b/lib/logging.dart
@@ -138,16 +138,26 @@ class Logger {
* If [message] is a [Function], it will be lazy evaluated. Additionally, if
* [message] or its evaluated value is not a [String], then 'toString()' will
* be called on it and the result will be logged.
+ *
+ * The log record will contain a field for the zone in which this call was
+ * made.
+ * This can be advantagous if a log listener wants to handle records of
+ * different zones differently (e.g. group log records by http-request if each
+ * http-request handler runs in it's own zone).
*/
- void log(Level logLevel, message, [Object error, StackTrace stackTrace]) {
+ 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 (zone == null) zone = Zone.current;
var record = new LogRecord(logLevel, message, fullName, error,
- stackTrace);
+ stackTrace, zone);
if (hierarchicalLoggingEnabled) {
var target = this;
@@ -314,8 +324,12 @@ class LogRecord {
/** Associated stackTrace (if any) when recording errors messages. */
final StackTrace stackTrace;
+ /** Zone of the calling code which resulted in this LogRecord. */
+ final Zone zone;
+
LogRecord(this.level, this.message, this.loggerName, [this.error,
- this.stackTrace])
+ this.stackTrace,
+ this.zone])
: time = new DateTime.now(),
sequenceNumber = LogRecord._nextNumber++;
« 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