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/. 6 * 7 * For more information on this interface, please see 8 * https://console.spec.whatwg.org/#console-namespace 9 */ 10 11[Exposed=(Window,Worker,WorkerDebugger,Worklet,System), 12 ClassString="Console", 13 ProtoObjectHack] 14namespace console { 15 16 // NOTE: if you touch this namespace, remember to update the ConsoleInstance 17 // interface as well! 18 19 // Logging 20 [UseCounter] 21 void assert(optional boolean condition = false, any... data); 22 [UseCounter] 23 void clear(); 24 [UseCounter] 25 void count(optional DOMString label = "default"); 26 [UseCounter] 27 void countReset(optional DOMString label = "default"); 28 [UseCounter] 29 void debug(any... data); 30 [UseCounter] 31 void error(any... data); 32 [UseCounter] 33 void info(any... data); 34 [UseCounter] 35 void log(any... data); 36 [UseCounter] 37 void table(any... data); // FIXME: The spec is still unclear about this. 38 [UseCounter] 39 void trace(any... data); 40 [UseCounter] 41 void warn(any... data); 42 [UseCounter] 43 void dir(any... data); // FIXME: This doesn't follow the spec yet. 44 [UseCounter] 45 void dirxml(any... data); 46 47 // Grouping 48 [UseCounter] 49 void group(any... data); 50 [UseCounter] 51 void groupCollapsed(any... data); 52 [UseCounter] 53 void groupEnd(); 54 55 // Timing 56 [UseCounter] 57 void time(optional DOMString label = "default"); 58 [UseCounter] 59 void timeLog(optional DOMString label = "default", any... data); 60 [UseCounter] 61 void timeEnd(optional DOMString label = "default"); 62 63 // Mozilla only or Webcompat methods 64 65 [UseCounter] 66 void _exception(any... data); 67 [UseCounter] 68 void timeStamp(optional any data); 69 70 [UseCounter] 71 void profile(any... data); 72 [UseCounter] 73 void profileEnd(any... data); 74 75 // invalid widl 76 // [ChromeOnly] 77 // const boolean IS_NATIVE_CONSOLE = true; 78 79 [ChromeOnly, NewObject] 80 ConsoleInstance createInstance(optional ConsoleInstanceOptions options); 81}; 82 83// This is used to propagate console events to the observers. 84dictionary ConsoleEvent { 85 (unsigned long long or DOMString) ID; 86 (unsigned long long or DOMString) innerID; 87 DOMString consoleID = ""; 88 DOMString addonId = ""; 89 DOMString level = ""; 90 DOMString filename = ""; 91 unsigned long lineNumber = 0; 92 unsigned long columnNumber = 0; 93 DOMString functionName = ""; 94 double timeStamp = 0; 95 sequence<any> arguments; 96 sequence<DOMString?> styles; 97 boolean private = false; 98 // stacktrace is handled via a getter in some cases so we can construct it 99 // lazily. Note that we're not making this whole thing an interface because 100 // consumers expect to see own properties on it, which would mean making the 101 // props unforgeable, which means lots of JSFunction allocations. Maybe we 102 // should fix those consumers, of course.... 103 // sequence<ConsoleStackEntry> stacktrace; 104 DOMString groupName = ""; 105 any timer = null; 106 any counter = null; 107 DOMString prefix = ""; 108}; 109 110// Event for profile operations 111dictionary ConsoleProfileEvent { 112 DOMString action = ""; 113 sequence<any> arguments; 114}; 115 116// This dictionary is used to manage stack trace data. 117dictionary ConsoleStackEntry { 118 DOMString filename = ""; 119 unsigned long lineNumber = 0; 120 unsigned long columnNumber = 0; 121 DOMString functionName = ""; 122 DOMString? asyncCause; 123}; 124 125dictionary ConsoleTimerStart { 126 DOMString name = ""; 127}; 128 129dictionary ConsoleTimerLogOrEnd { 130 DOMString name = ""; 131 double duration = 0; 132}; 133 134dictionary ConsoleTimerError { 135 DOMString error = ""; 136 DOMString name = ""; 137}; 138 139dictionary ConsoleCounter { 140 DOMString label = ""; 141 unsigned long count = 0; 142}; 143 144dictionary ConsoleCounterError { 145 DOMString label = ""; 146 DOMString error = ""; 147}; 148 149[ChromeOnly, 150 Exposed=(Window,Worker,WorkerDebugger,Worklet,System)] 151// This is basically a copy of the console namespace. 152interface ConsoleInstance { 153 // Logging 154 void assert(optional boolean condition = false, any... data); 155 void clear(); 156 void count(optional DOMString label = "default"); 157 void countReset(optional DOMString label = "default"); 158 void debug(any... data); 159 void error(any... data); 160 void info(any... data); 161 void log(any... data); 162 void table(any... data); // FIXME: The spec is still unclear about this. 163 void trace(any... data); 164 void warn(any... data); 165 void dir(any... data); // FIXME: This doesn't follow the spec yet. 166 void dirxml(any... data); 167 168 // Grouping 169 void group(any... data); 170 void groupCollapsed(any... data); 171 void groupEnd(); 172 173 // Timing 174 void time(optional DOMString label = "default"); 175 void timeLog(optional DOMString label = "default", any... data); 176 void timeEnd(optional DOMString label = "default"); 177 178 // Mozilla only or Webcompat methods 179 180 void _exception(any... data); 181 void timeStamp(optional any data); 182 183 void profile(any... data); 184 void profileEnd(any... data); 185}; 186 187callback ConsoleInstanceDumpCallback = void (DOMString message); 188 189enum ConsoleLogLevel { 190 "All", "Debug", "Log", "Info", "Clear", "Trace", "TimeLog", "TimeEnd", "Time", 191 "Group", "GroupEnd", "Profile", "ProfileEnd", "Dir", "Dirxml", "Warn", "Error", 192 "Off" 193}; 194 195dictionary ConsoleInstanceOptions { 196 // An optional function to intercept all strings written to stdout. 197 ConsoleInstanceDumpCallback dump; 198 199 // An optional prefix string to be printed before the actual logged message. 200 DOMString prefix = ""; 201 202 // An ID representing the source of the message. Normally the inner ID of a 203 // DOM window. 204 DOMString innerID = ""; 205 206 // String identified for the console, this will be passed through the console 207 // notifications. 208 DOMString consoleID = ""; 209 210 // Identifier that allows to filter which messages are logged based on their 211 // log level. 212 ConsoleLogLevel maxLogLevel; 213 214 // String pref name which contains the level to use for maxLogLevel. If the 215 // pref doesn't exist, gets removed or it is used in workers, the maxLogLevel 216 // will default to the value passed to this constructor (or "all" if it wasn't 217 // specified). 218 DOMString maxLogLevelPref = ""; 219}; 220 221enum ConsoleLevel { "log", "warning", "error" }; 222 223// this interface is just for testing 224partial interface ConsoleInstance { 225 [ChromeOnly] 226 void reportForServiceWorkerScope(DOMString scope, DOMString message, 227 DOMString filename, unsigned long lineNumber, 228 unsigned long columnNumber, 229 ConsoleLevel level); 230}; 231