1 /* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 * For more information on this interface, please see
8 * https://console.spec.whatwg.org/#console-namespace
11 [Exposed=(Window,Worker,WorkerDebugger,Worklet),
12 ClassString="Console",
16 // NOTE: if you touch this namespace, remember to update the ConsoleInstance
21 void assert(optional boolean condition = false, any... data);
25 void count(optional DOMString label = "default");
27 void countReset(optional DOMString label = "default");
29 void debug(any... data);
31 void error(any... data);
33 void info(any... data);
35 void log(any... data);
37 void table(any... data); // FIXME: The spec is still unclear about this.
39 void trace(any... data);
41 void warn(any... data);
43 void dir(any... data); // FIXME: This doesn't follow the spec yet.
45 void dirxml(any... data);
49 void group(any... data);
51 void groupCollapsed(any... data);
57 void time(optional DOMString label = "default");
59 void timeLog(optional DOMString label = "default", any... data);
61 void timeEnd(optional DOMString label = "default");
63 // Mozilla only or Webcompat methods
66 void _exception(any... data);
68 void timeStamp(optional any data);
71 void profile(any... data);
73 void profileEnd(any... data);
76 const boolean IS_NATIVE_CONSOLE = true;
78 [ChromeOnly, NewObject]
79 ConsoleInstance createInstance(optional ConsoleInstanceOptions options = {});
82 // This is used to propagate console events to the observers.
83 [GenerateConversionToJS]
84 dictionary ConsoleEvent {
85 (unsigned long long or DOMString) ID;
86 (unsigned long long or DOMString) innerID;
87 DOMString consoleID = "";
88 DOMString addonId = "";
90 DOMString filename = "";
91 // Unique identifier within the process for the script source this event is
92 // associated with, or zero.
93 unsigned long sourceId = 0;
94 unsigned long lineNumber = 0;
95 unsigned long columnNumber = 0;
96 DOMString functionName = "";
98 sequence<any> arguments;
99 sequence<DOMString?> styles;
100 boolean private = false;
101 // stacktrace is handled via a getter in some cases so we can construct it
102 // lazily. Note that we're not making this whole thing an interface because
103 // consumers expect to see own properties on it, which would mean making the
104 // props unforgeable, which means lots of JSFunction allocations. Maybe we
105 // should fix those consumers, of course....
106 // sequence<ConsoleStackEntry> stacktrace;
107 DOMString groupName = "";
110 DOMString prefix = "";
111 boolean chromeContext = false;
114 // Event for profile operations
115 [GenerateConversionToJS]
116 dictionary ConsoleProfileEvent {
117 DOMString action = "";
118 sequence<any> arguments;
119 boolean chromeContext = false;
122 // This dictionary is used to manage stack trace data.
123 [GenerateConversionToJS]
124 dictionary ConsoleStackEntry {
125 DOMString filename = "";
126 // Unique identifier within the process for the script source this entry is
127 // associated with, or zero.
128 unsigned long sourceId = 0;
129 unsigned long lineNumber = 0;
130 unsigned long columnNumber = 0;
131 DOMString functionName = "";
132 DOMString? asyncCause;
135 [GenerateConversionToJS]
136 dictionary ConsoleTimerStart {
140 [GenerateConversionToJS]
141 dictionary ConsoleTimerLogOrEnd {
146 [GenerateConversionToJS]
147 dictionary ConsoleTimerError {
148 DOMString error = "";
152 [GenerateConversionToJS]
153 dictionary ConsoleCounter {
154 DOMString label = "";
155 unsigned long count = 0;
158 [GenerateConversionToJS]
159 dictionary ConsoleCounterError {
160 DOMString label = "";
161 DOMString error = "";
165 Exposed=(Window,Worker,WorkerDebugger,Worklet)]
166 // This is basically a copy of the console namespace.
167 interface ConsoleInstance {
169 void assert(optional boolean condition = false, any... data);
171 void count(optional DOMString label = "default");
172 void countReset(optional DOMString label = "default");
173 void debug(any... data);
174 void error(any... data);
175 void info(any... data);
176 void log(any... data);
177 void table(any... data); // FIXME: The spec is still unclear about this.
178 void trace(any... data);
179 void warn(any... data);
180 void dir(any... data); // FIXME: This doesn't follow the spec yet.
181 void dirxml(any... data);
184 void group(any... data);
185 void groupCollapsed(any... data);
189 void time(optional DOMString label = "default");
190 void timeLog(optional DOMString label = "default", any... data);
191 void timeEnd(optional DOMString label = "default");
193 // Mozilla only or Webcompat methods
195 void _exception(any... data);
196 void timeStamp(optional any data);
198 void profile(any... data);
199 void profileEnd(any... data);
202 callback ConsoleInstanceDumpCallback = void (DOMString message);
204 enum ConsoleLogLevel {
205 "All", "Debug", "Log", "Info", "Clear", "Trace", "TimeLog", "TimeEnd", "Time",
206 "Group", "GroupEnd", "Profile", "ProfileEnd", "Dir", "Dirxml", "Warn", "Error",
210 dictionary ConsoleInstanceOptions {
211 // An optional function to intercept all strings written to stdout.
212 ConsoleInstanceDumpCallback dump;
214 // An optional prefix string to be printed before the actual logged message.
215 DOMString prefix = "";
217 // An ID representing the source of the message. Normally the inner ID of a
219 DOMString innerID = "";
221 // String identified for the console, this will be passed through the console
223 DOMString consoleID = "";
225 // Identifier that allows to filter which messages are logged based on their
227 ConsoleLogLevel maxLogLevel;
229 // String pref name which contains the level to use for maxLogLevel. If the
230 // pref doesn't exist, gets removed or it is used in workers, the maxLogLevel
231 // will default to the value passed to this constructor (or "all" if it wasn't
233 DOMString maxLogLevelPref = "";
236 enum ConsoleLevel { "log", "warning", "error" };
238 // this interface is just for testing
239 partial interface ConsoleInstance {
241 void reportForServiceWorkerScope(DOMString scope, DOMString message,
242 DOMString filename, unsigned long lineNumber,
243 unsigned long columnNumber,