-
Notifications
You must be signed in to change notification settings - Fork 74
Specify console.context #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nchevobbe
wants to merge
4
commits into
whatwg:main
Choose a base branch
from
nchevobbe:console-context
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 = ""); | ||
| }; | ||
| </pre> | ||
|
|
||
|
|
@@ -103,7 +106,7 @@ its \[[Prototype]] an empty object, created as if by | |
|
|
||
| <h3 id="logging">Logging functions</h3> | ||
|
|
||
| <h4 id="assert" oldids="assert-condition-data,dom-console-assert" method for="console">assert(|condition|, ...|data|)</h4> | ||
| <h4 id="assert" oldids="assert-condition-data,dom-console-assert" method for="console,ConsoleContext">assert(|condition|, ...|data|)</h4> | ||
|
|
||
| 1. If |condition| is true, return. | ||
| 1. Let |message| be a string without any formatting specifiers indicating generically an assertion | ||
|
|
@@ -117,36 +120,36 @@ its \[[Prototype]] an empty object, created as if by | |
| 1. Set |data|[0] to |concat|. | ||
| 1. Perform <a abstract-op>Logger</a>("assert", |data|). | ||
|
|
||
| <h4 id="clear" oldids="dom-console-clear" method for="console">clear()</h4> | ||
| <h4 id="clear" oldids="dom-console-clear" method for="console,ConsoleContext">clear()</h4> | ||
|
|
||
| 1. [=stack/Empty=] the appropriate <a>group stack</a>. | ||
| 1. If possible for the environment, clear the console. (Otherwise, do nothing.) | ||
|
|
||
| <h4 id="debug" oldids="debug-data,dom-console-debug" method for="console">debug(...|data|)</h4> | ||
| <h4 id="debug" oldids="debug-data,dom-console-debug" method for="console,ConsoleContext">debug(...|data|)</h4> | ||
|
|
||
| 1. Perform <a abstract-op>Logger</a>("debug", |data|). | ||
|
|
||
| <h4 id="error" oldids="error-data,dom-console-error" method for="console">error(...|data|)</h4> | ||
| <h4 id="error" oldids="error-data,dom-console-error" method for="console,ConsoleContext">error(...|data|)</h4> | ||
|
|
||
| 1. Perform <a abstract-op>Logger</a>("error", |data|). | ||
|
|
||
| <h4 id="info" oldids="info-data,dom-console-info" method for="console">info(...|data|)</h4> | ||
| <h4 id="info" oldids="info-data,dom-console-info" method for="console,ConsoleContext">info(...|data|)</h4> | ||
|
|
||
| 1. Perform <a abstract-op>Logger</a>("info", |data|). | ||
|
|
||
| <h4 id="log" oldids="log-data,dom-console-log" method for="console">log(...|data|)</h4> | ||
| <h4 id="log" oldids="log-data,dom-console-log" method for="console,ConsoleContext">log(...|data|)</h4> | ||
|
|
||
| 1. Perform <a abstract-op>Logger</a>("log", |data|). | ||
|
|
||
| <h4 id="table" oldids="table-tabulardata-properties,dom-console-table" method for="console">table(|tabularData|, |properties|)</h4> | ||
| <h4 id="table" oldids="table-tabulardata-properties,dom-console-table" method for="console,ConsoleContext">table(|tabularData|, |properties|)</h4> | ||
|
|
||
| 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 | ||
| back to just logging the argument if it can't be parsed as tabular. | ||
|
|
||
| <p class="XXX">TODO: This will need a good algorithm.</p> | ||
|
|
||
| <h4 id="trace" oldids="trace-data,dom-console-trace" method for="console">trace(...|data|)</h4> | ||
| <h4 id="trace" oldids="trace-data,dom-console-trace" method for="console,ConsoleContext">trace(...|data|)</h4> | ||
|
|
||
| 1. Let |trace| be some <a>implementation-defined</a>, 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`. | ||
| </p> | ||
|
|
||
| <h4 id="warn" oldids="warn-data,dom-console-warn" method for="console">warn(...|data|)</h4> | ||
| <h4 id="warn" oldids="warn-data,dom-console-warn" method for="console,ConsoleContext">warn(...|data|)</h4> | ||
|
|
||
| 1. Perform <a abstract-op>Logger</a>("warn", |data|). | ||
|
|
||
| <h4 id="dir" method for="console">dir(|item|, |options|)</h4> | ||
| <h4 id="dir" method for="console,ConsoleContext">dir(|item|, |options|)</h4> | ||
|
|
||
| 1. Let |object| be |item| with <a>generic JavaScript object formatting</a> applied. | ||
| 1. Perform <a abstract-op>Printer</a>("dir", « |object| », |options|). | ||
|
|
||
| <h4 id="dirxml" method for="console">dirxml(...|data|)</h4> | ||
| <h4 id="dirxml" method for="console,ConsoleContext">dirxml(...|data|)</h4> | ||
|
|
||
| 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. | |
|
|
||
| <h3 id="counting">Counting functions</h3> | ||
|
|
||
| Each {{console}} namespace object has an associated <dfn>count map</dfn>, which is a <a>map</a> of | ||
| Each {{console}} namespace object and {{ConsoleContext}} instance has an associated <dfn>count map</dfn>, which is a <a>map</a> of | ||
| <a>strings</a> to numbers, initially empty. | ||
|
|
||
| <h4 id="count" oldids="count-label,dom-console-count" method for="console">count(|label|)</h4> | ||
| <h4 id="count" oldids="count-label,dom-console-count" method for="console,ConsoleContext">count(|label|)</h4> | ||
|
|
||
| 1. Let |map| be the associated <a>count map</a>. | ||
| 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 <dfn>count map</dfn>, which | |
| <a abstract-op>ToString</a>(|map|[|label|]). | ||
| 1. Perform <a abstract-op>Logger</a>("count", « |concat| »). | ||
|
|
||
| <h4 id="countreset" method for="console">countReset(|label|)</h4> | ||
| <h4 id="countreset" method for="console,ConsoleContext">countReset(|label|)</h4> | ||
|
|
||
| 1. Let |map| be the associated <a>count map</a>. | ||
| 1. If |map|[|label|] [=map/exists=], [=map/set=] |map|[|label|] to 0. | ||
|
|
@@ -204,11 +207,11 @@ Each {{console}} namespace object has an associated <dfn>count map</dfn>, which | |
|
|
||
| A <dfn id="concept-group">group</dfn> is an <a>implementation-defined</a>, potentially-interactive | ||
| view for output produced by calls to <a abstract-op>Printer</a>, with one further level of | ||
| indentation than its parent. Each {{console}} namespace object has an associated <dfn>group | ||
| indentation than its parent. Each {{console}} namespace object and {{ConsoleContext}} instance has an associated <dfn>group | ||
| stack</dfn>, which is a <a>stack</a>, initially empty. Only the last <a>group</a> in a <a>group | ||
| stack</a> will host output produced by calls to <a abstract-op>Printer</a>. | ||
|
|
||
| <h4 id="group" oldids="group-data,dom-console-group" method for="console">group(...|data|)</h4> | ||
| <h4 id="group" oldids="group-data,dom-console-group" method for="console,ConsoleContext">group(...|data|)</h4> | ||
|
|
||
| 1. Let |group| be a new <a>group</a>. | ||
| 1. If |data| is not [=list/is empty|empty=], let |groupLabel| be the result of | ||
|
|
@@ -220,7 +223,7 @@ stack</a> will host output produced by calls to <a abstract-op>Printer</a>. | |
| 1. Perform <a abstract-op>Printer</a>("group", « |group| »). | ||
| 1. [=stack/Push=] |group| onto the appropriate <a>group stack</a>. | ||
|
|
||
| <h4 id="groupcollapsed" oldids="groupcollapsed-data,dom-console-groupcollapsed" method for="console">groupCollapsed(...|data|)</h4> | ||
| <h4 id="groupcollapsed" oldids="groupcollapsed-data,dom-console-groupcollapsed" method for="console,ConsoleContext">groupCollapsed(...|data|)</h4> | ||
|
|
||
| 1. Let |group| be a new <a>group</a>. | ||
| 1. If |data| is not empty, let |groupLabel| be the result of | ||
|
|
@@ -232,7 +235,7 @@ stack</a> will host output produced by calls to <a abstract-op>Printer</a>. | |
| 1. Perform <a abstract-op>Printer</a>("groupCollapsed", « |group| »). | ||
| 1. [=stack/Push=] |group| onto the appropriate <a>group stack</a>. | ||
|
|
||
| <h4 id="groupend" oldids="dom-console-groupend" method for="console">groupEnd()</h4> | ||
| <h4 id="groupend" oldids="dom-console-groupend" method for="console,ConsoleContext">groupEnd()</h4> | ||
|
|
||
| 1. <a>Pop</a> the last <a>group</a> from the <a>group stack</a>. | ||
|
|
||
|
|
@@ -241,15 +244,15 @@ stack</a> will host output produced by calls to <a abstract-op>Printer</a>. | |
| Each {{console}} namespace object has an associated <dfn>timer table</dfn>, which is a <a>map</a> of | ||
| <a>strings</a> to times, initially empty. | ||
|
|
||
| <h4 id="time" oldids="time-label,dom-console-time" method for="console">time(|label|)</h4> | ||
| <h4 id="time" oldids="time-label,dom-console-time" method for="console,ConsoleContext">time(|label|)</h4> | ||
|
|
||
| 1. If the associated <a>timer table</a> [=map/contains=] an entry with key |label|, return, | ||
| optionally reporting a warning to the console indicating that a timer with label |label| has | ||
| already been started. | ||
| 1. Otherwise, [=map/set=] the value of the entry with key |label| in the associated | ||
| <a>timer table</a> to the current time. | ||
|
|
||
| <h4 id="timelog" method for="console">timeLog(|label|, ...|data|)</h4> | ||
| <h4 id="timelog" method for="console,ConsoleContext">timeLog(|label|, ...|data|)</h4> | ||
|
|
||
| 1. Let |timerTable| be the associated <a>timer table</a>. | ||
| 1. Let |startTime| be |timerTable|[|label|]. | ||
|
|
@@ -278,7 +281,7 @@ Each {{console}} namespace object has an associated <dfn>timer table</dfn>, whic | |
| </code></pre> | ||
| </div> | ||
|
|
||
| <h4 id="timeend" oldids="timeend-label,dom-console-timeend" method for="console">timeEnd(|label|)</h4> | ||
| <h4 id="timeend" oldids="timeend-label,dom-console-timeend" method for="console,ConsoleContext">timeEnd(|label|)</h4> | ||
|
|
||
| 1. Let |timerTable| be the associated <a>timer table</a>. | ||
| 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 <a>timer table</a>. | ||
| </p> | ||
|
|
||
| <h3 id="contextualizing">Contextualizing</h3> | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, not convinced about this name |
||
|
|
||
| Each {{ConsoleContext}} instance has an associated <dfn>context name</dfn>, empty by default. | ||
|
|
||
| <h4 id="context" method for="console">context(|label|)</h4> | ||
|
|
||
| 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 <a>context name</a> to |contextName|. | ||
| 1. Return |context|. | ||
|
|
||
| <h2 id="the-consolecontext-interface">The {{ConsoleContext}} interface</h2> | ||
|
|
||
| The IDL for the {{ConsoleContext}} interface is as follows, with the various methods defined in the {{console}} section: | ||
|
|
||
| <pre class="idl"> | ||
| [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"); | ||
| }; | ||
| </pre> | ||
|
|
||
| <h2 id="supporting-ops">Supporting abstract operations</h2> | ||
|
|
||
| <h3 id="logger" abstract-op lt="Logger">Logger(|logLevel|, |args|)</h3> | ||
|
|
@@ -515,6 +566,9 @@ enhancements: | |
| src="images/severity-filter.png"> | ||
| </div> | ||
| </li> | ||
| <li> | ||
| Extra UI allowing the user to filter messages by context name | ||
| </li> | ||
| <li> | ||
| Extra UI off to the side indicating the current state of the <a>timer table</a>, | ||
| <a>group stack</a>, or other internally maintained data. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like this name, but couldn't find anything that would suit this. Maybe we don't need a "section" comment here? I was trying to replicate what was already there