diff --git a/index.bs b/index.bs index ed89c77..e3c1494 100644 --- a/index.bs +++ b/index.bs @@ -68,6 +68,7 @@ namespace console { // but see namespace object requirements below // Timing void time(optional DOMString label = "default"); + void timeLog(optional DOMString label = "default", any... data); void timeEnd(optional DOMString label = "default"); }; @@ -78,8 +79,7 @@ namespace console { // but see namespace object requirements below

It is important that {{console}} is always visible and usable to scripts, even if the developer - console has not been opened or - does not exist. + console has not been opened or does not exist.

For historical web-compatibility reasons, the namespace object for {{console}} must have as @@ -234,16 +234,49 @@ Each {{console}} namespace object has an associated timer table, whic 1. Otherwise, [=map/set=] the value of the entry with key |label| in the associated timer table to the current time. -

timeEnd(|label|)

+

timeLog(|label|, ...|data|)

-1. Let |startTime| be the result of [=map/getting=] the value of the entry with key |label| in the - associated timer table. +1. Let |timerTable| be the associated timer table. +1. Let |startTime| be |timerTable|[|label|]. 1. Let |duration| be a string representing the difference between the current time and |startTime|, in an implementation-defined format.

"4650", "4650.69 ms", "5 seconds", and "00:05" are all reasonable ways of displaying a 4650.69 ms duration.

1. Let |concat| be the concatenation of |label|, U+003A (:), U+0020 SPACE, and |duration|. -1. Perform Logger("timeEnd", « |concat| »). +1. [=list/prepend|Prepend=] |concat| to |data|. +1. Perform Printer("timeLog", data). + +
+ The |data| parameter in calls to {{console/timeLog()}} is included in the call to + Logger to make it easier for users to supply intermediate timer logs with + some extra data throughout the life of a timer. For example: + +

+    console.time("MyTimer");
+    console.timeLog("MyTimer", "Starting application up…");
+    // Perhaps some code runs to boostrap a complex app
+    // ...
+    console.timeLog("MyTimer", "UI is setup, making API calls now");
+    // Perhaps some fetch()'s here filling the app with data
+    // ...
+    console.timeEnd("MyTimer");
+  
+
+ +

timeEnd(|label|)

+ +1. Let |timerTable| be the associated timer table. +1. Let |startTime| be |timerTable|[|label|]. +1. [=map/Remove=] |timerTable|[|label|]. +1. Let |duration| be a string representing the difference between the current time and + |startTime|, in an implementation-defined format. +1. Let |concat| be the concatenation of |label|, U+003A (:), U+0020 SPACE, and |duration|. +1. Perform Printer("timeEnd", « |concat| »). + +

See whatwg/console#134 +for plans to make {{console/timeEnd()}} and {{console/timeLog()}} formally report warnings to the +console when a given |label| does not exist in the associated timer table. +

Supporting abstract operations

@@ -394,7 +427,7 @@ their output similarly, in four broad categories. This table summarizes these co log {{console/log()}}, {{console/trace()}}, {{console/dir()}}, {{console/dirxml()}}, - {{console/group()}}, {{console/groupCollapsed()}}, {{console/debug()}} + {{console/group()}}, {{console/groupCollapsed()}}, {{console/debug()}}, {{console/timeLog()}} A generic log