ConsoleInstance.webidl (5844B)
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 // This is used to propagate console events to the observers. 12 [GenerateConversionToJS] 13 dictionary ConsoleEvent { 14 (unsigned long long or DOMString) ID; 15 (unsigned long long or DOMString) innerID; 16 DOMString consoleID = ""; 17 DOMString addonId = ""; 18 DOMString level = ""; 19 UTF8String filename = ""; 20 // Unique identifier within the process for the script source this event is 21 // associated with, or zero. 22 unsigned long sourceId = 0; 23 unsigned long lineNumber = 0; 24 unsigned long columnNumber = 0; 25 DOMString functionName = ""; 26 double timeStamp = 0; 27 double microSecondTimeStamp = 0; 28 sequence<any> arguments; 29 sequence<DOMString?> styles; 30 boolean private = false; 31 // stacktrace is handled via a getter in some cases so we can construct it 32 // lazily. Note that we're not making this whole thing an interface because 33 // consumers expect to see own properties on it, which would mean making the 34 // props unforgeable, which means lots of JSFunction allocations. Maybe we 35 // should fix those consumers, of course.... 36 // sequence<ConsoleStackEntry> stacktrace; 37 DOMString groupName = ""; 38 any timer = null; 39 any counter = null; 40 DOMString prefix = ""; 41 boolean chromeContext = false; 42 }; 43 44 // Event for profile operations 45 [GenerateConversionToJS] 46 dictionary ConsoleProfileEvent { 47 DOMString action = ""; 48 sequence<any> arguments; 49 boolean chromeContext = false; 50 }; 51 52 // This dictionary is used to manage stack trace data. 53 [GenerateConversionToJS] 54 dictionary ConsoleStackEntry { 55 UTF8String filename = ""; 56 // Unique identifier within the process for the script source this entry is 57 // associated with, or zero. 58 unsigned long sourceId = 0; 59 unsigned long lineNumber = 0; 60 unsigned long columnNumber = 0; 61 DOMString functionName = ""; 62 DOMString? asyncCause; 63 }; 64 65 [GenerateConversionToJS] 66 dictionary ConsoleTimerStart { 67 DOMString name = ""; 68 }; 69 70 [GenerateConversionToJS] 71 dictionary ConsoleTimerLogOrEnd { 72 DOMString name = ""; 73 double duration = 0; 74 }; 75 76 [GenerateConversionToJS] 77 dictionary ConsoleTimerError { 78 DOMString error = ""; 79 DOMString name = ""; 80 }; 81 82 [GenerateConversionToJS] 83 dictionary ConsoleCounter { 84 DOMString label = ""; 85 unsigned long count = 0; 86 }; 87 88 [GenerateConversionToJS] 89 dictionary ConsoleCounterError { 90 DOMString label = ""; 91 DOMString error = ""; 92 }; 93 94 [ChromeOnly, 95 Exposed=(Window,Worker,WorkerDebugger,Worklet)] 96 // This is basically a copy of the console namespace. 97 interface ConsoleInstance { 98 // Logging 99 undefined assert(optional boolean condition = false, any... data); 100 undefined clear(); 101 undefined count(optional DOMString label = "default"); 102 undefined countReset(optional DOMString label = "default"); 103 undefined debug(any... data); 104 undefined error(any... data); 105 undefined info(any... data); 106 undefined log(any... data); 107 undefined table(any... data); // FIXME: The spec is still unclear about this. 108 undefined trace(any... data); 109 undefined warn(any... data); 110 undefined dir(any... data); // FIXME: This doesn't follow the spec yet. 111 undefined dirxml(any... data); 112 113 // Grouping 114 undefined group(any... data); 115 undefined groupCollapsed(any... data); 116 undefined groupEnd(); 117 118 // Timing 119 undefined time(optional DOMString label = "default"); 120 undefined timeLog(optional DOMString label = "default", any... data); 121 undefined timeEnd(optional DOMString label = "default"); 122 123 // Mozilla only or Webcompat methods 124 125 undefined _exception(any... data); 126 undefined timeStamp(optional any data); 127 128 undefined profile(any... data); 129 undefined profileEnd(any... data); 130 131 // Returns true if the given level would log a message. Used for avoiding 132 // long/significant processing when logging messages. 133 boolean shouldLog(ConsoleLogLevel level); 134 }; 135 136 callback ConsoleInstanceDumpCallback = undefined (DOMString message); 137 138 enum ConsoleLogLevel { 139 "All", "Debug", "Log", "Info", "Clear", "Trace", "TimeLog", "TimeEnd", "Time", 140 "Group", "GroupEnd", "Profile", "ProfileEnd", "Dir", "Dirxml", "Warn", "Error", 141 "Off" 142 }; 143 144 dictionary ConsoleInstanceOptions { 145 // An optional function to intercept all strings written to stdout. 146 ConsoleInstanceDumpCallback dump; 147 148 // An optional prefix string to be printed before the actual logged message. 149 DOMString prefix = ""; 150 151 // An ID representing the source of the message. Normally the inner ID of a 152 // DOM window. 153 DOMString innerID = ""; 154 155 // String identified for the console, this will be passed through the console 156 // notifications. 157 DOMString consoleID = ""; 158 159 // Identifier that allows to filter which messages are logged based on their 160 // log level. 161 ConsoleLogLevel maxLogLevel; 162 163 // String pref name which contains the level to use for maxLogLevel. If the 164 // pref doesn't exist, gets removed or it is used in workers, the maxLogLevel 165 // will default to the value passed to this constructor (or "all" if it wasn't 166 // specified). 167 UTF8String maxLogLevelPref = ""; 168 }; 169 170 enum ConsoleLevel { "log", "warning", "error" }; 171 172 // this interface is just for testing 173 partial interface ConsoleInstance { 174 [ChromeOnly] 175 undefined reportForServiceWorkerScope(DOMString scope, DOMString message, 176 UTF8String filename, 177 unsigned long lineNumber, 178 unsigned long columnNumber, 179 ConsoleLevel level); 180 };