diff --git a/index.bs b/index.bs index 2e007cd..97caa57 100644 --- a/index.bs +++ b/index.bs @@ -85,6 +85,9 @@ namespace console { // but see namespace object requirements below undefined time(optional DOMString label = "default"); undefined timeLog(optional DOMString label = "default", any... data); undefined timeEnd(optional DOMString label = "default"); + + // Contextualizing + ConsoleContext context(optional DOMString label = ""); }; @@ -103,7 +106,7 @@ its \[[Prototype]] an empty object, created as if by

Logging functions

-

assert(|condition|, ...|data|)

+

assert(|condition|, ...|data|)

1. If |condition| is true, return. 1. Let |message| be a string without any formatting specifiers indicating generically an assertion @@ -117,28 +120,28 @@ its \[[Prototype]] an empty object, created as if by 1. Set |data|[0] to |concat|. 1. Perform Logger("assert", |data|). -

clear()

+

clear()

1. [=stack/Empty=] the appropriate group stack. 1. If possible for the environment, clear the console. (Otherwise, do nothing.) -

debug(...|data|)

+

debug(...|data|)

1. Perform Logger("debug", |data|). -

error(...|data|)

+

error(...|data|)

1. Perform Logger("error", |data|). -

info(...|data|)

+

info(...|data|)

1. Perform Logger("info", |data|). -

log(...|data|)

+

log(...|data|)

1. Perform Logger("log", |data|). -

table(|tabularData|, |properties|)

+

table(|tabularData|, |properties|)

Try to construct a table with the columns of the properties of |tabularData| (or use |properties|) and rows of |tabularData| and log it with a logLevel of "log". Fall @@ -146,7 +149,7 @@ back to just logging the argument if it can't be parsed as tabular.

TODO: This will need a good algorithm.

-

trace(...|data|)

+

trace(...|data|)

1. Let |trace| be some implementation-defined, potentially-interactive representation of the callstack from where this function was called. @@ -159,16 +162,16 @@ back to just logging the argument if it can't be parsed as tabular. not guaranteed to be the same identifier that would be seen in `new Error().stack`.

-

warn(...|data|)

+

warn(...|data|)

1. Perform Logger("warn", |data|). -

dir(|item|, |options|)

+

dir(|item|, |options|)

1. Let |object| be |item| with generic JavaScript object formatting applied. 1. Perform Printer("dir", « |object| », |options|). -

dirxml(...|data|)

+

dirxml(...|data|)

1. Let |finalList| be a new [=/list=], initially empty. 1. [=list/For each=] |item| of |data|: @@ -179,10 +182,10 @@ back to just logging the argument if it can't be parsed as tabular.

Counting functions

-Each {{console}} namespace object has an associated count map, which is a map of +Each {{console}} namespace object and {{ConsoleContext}} instance has an associated count map, which is a map of strings to numbers, initially empty. -

count(|label|)

+

count(|label|)

1. Let |map| be the associated count map. 1. If |map|[|label|] [=map/exists=], [=map/set=] |map|[|label|] to |map|[|label|] + 1. @@ -191,7 +194,7 @@ Each {{console}} namespace object has an associated count map, which ToString(|map|[|label|]). 1. Perform Logger("count", « |concat| »). -

countReset(|label|)

+

countReset(|label|)

1. Let |map| be the associated count map. 1. If |map|[|label|] [=map/exists=], [=map/set=] |map|[|label|] to 0. @@ -204,11 +207,11 @@ Each {{console}} namespace object has an associated count map, which A group is an implementation-defined, potentially-interactive view for output produced by calls to Printer, with one further level of -indentation than its parent. Each {{console}} namespace object has an associated group +indentation than its parent. Each {{console}} namespace object and {{ConsoleContext}} instance has an associated group stack, which is a stack, initially empty. Only the last group in a group stack will host output produced by calls to Printer. -

group(...|data|)

+

group(...|data|)

1. Let |group| be a new group. 1. If |data| is not [=list/is empty|empty=], let |groupLabel| be the result of @@ -220,7 +223,7 @@ stack will host output produced by calls to Printer. 1. Perform Printer("group", « |group| »). 1. [=stack/Push=] |group| onto the appropriate group stack. -

groupCollapsed(...|data|)

+

groupCollapsed(...|data|)

1. Let |group| be a new group. 1. If |data| is not empty, let |groupLabel| be the result of @@ -232,7 +235,7 @@ stack will host output produced by calls to Printer. 1. Perform Printer("groupCollapsed", « |group| »). 1. [=stack/Push=] |group| onto the appropriate group stack. -

groupEnd()

+

groupEnd()

1. Pop the last group from the group stack. @@ -241,7 +244,7 @@ stack will host output produced by calls to Printer. Each {{console}} namespace object has an associated timer table, which is a map of strings to times, initially empty. -

time(|label|)

+

time(|label|)

1. If the associated timer table [=map/contains=] an entry with key |label|, return, optionally reporting a warning to the console indicating that a timer with label |label| has @@ -249,7 +252,7 @@ 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. -

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

+

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

1. Let |timerTable| be the associated timer table. 1. Let |startTime| be |timerTable|[|label|]. @@ -278,7 +281,7 @@ Each {{console}} namespace object has an associated timer table, whic -

timeEnd(|label|)

+

timeEnd(|label|)

1. Let |timerTable| be the associated timer table. 1. Let |startTime| be |timerTable|[|label|]. @@ -293,6 +296,54 @@ for plans to make {{console/timeEnd()}} and {{console/timeLog()}} formally repor console when a given |label| does not exist in the associated timer table.

+

Contextualizing

+ +Each {{ConsoleContext}} instance has an associated context name, empty by default. + +

context(|label|)

+ +1. Let |context| be a new {{ConsoleContext}} instance. +1. Let |contextName| be the empty string. +1. If |label| is not null, then set |contextName| to |label|. +1. Set |context|'s context name to |contextName|. +1. Return |context|. + +

The {{ConsoleContext}} interface

+ +The IDL for the {{ConsoleContext}} interface is as follows, with the various methods defined in the {{console}} section: + +
+[Exposed=*]
+interface ConsoleContext {
+  // Logging
+  undefined assert(optional boolean condition = false, any... data);
+  undefined clear();
+  undefined debug(any... data);
+  undefined error(any... data);
+  undefined info(any... data);
+  undefined log(any... data);
+  undefined table(optional any tabularData, optional sequence<DOMString> properties);
+  undefined trace(any... data);
+  undefined warn(any... data);
+  undefined dir(optional any item, optional object? options);
+  undefined dirxml(any... data);
+
+  // Counting
+  undefined count(optional DOMString label = "default");
+  undefined countReset(optional DOMString label = "default");
+
+  // Grouping
+  undefined group(any... data);
+  undefined groupCollapsed(any... data);
+  undefined groupEnd();
+
+  // Timing
+  undefined time(optional DOMString label = "default");
+  undefined timeLog(optional DOMString label = "default", any... data);
+  undefined timeEnd(optional DOMString label = "default");
+};
+
+

Supporting abstract operations

Logger(|logLevel|, |args|)

@@ -515,6 +566,9 @@ enhancements: src="images/severity-filter.png"> +
  • + Extra UI allowing the user to filter messages by context name +
  • Extra UI off to the side indicating the current state of the timer table, group stack, or other internally maintained data.