001package Torello.Browser.BrowserAPI;
002
003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
004// Java-HTML Imports
005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
006
007import Torello.Browser.*;
008import Torello.Browser.helper.*;
009import Torello.Browser.JavaScriptAPI.*;
010import Torello.JSON.*;
011
012import Torello.Java.ReadOnly.ReadOnlyList;
013import Torello.Java.ReadOnly.ReadOnlyArrayList;
014
015import Torello.JavaDoc.Annotations.StaticFunctional;
016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg;
017
018
019// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
020// JDK Imports
021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
022
023import javax.json.JsonObject;
024import javax.json.JsonValue;
025
026/**
027 * <SPAN CLASS=COPIEDJDK><B>Provides access to log entries.</B></SPAN>
028 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE>
029 */
030@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE")
031public class Log
032{
033    // No Pubic Constructors
034    private Log() { }
035
036
037
038    // ********************************************************************************************
039    // ********************************************************************************************
040    // Basic Types
041    // ********************************************************************************************
042    // ********************************************************************************************
043
044
045    /**
046     * Log entry.
047     * 
048     * <EMBED CLASS=globalDefs DATA-DOMAIN=Log DATA-API=BrowserAPI>
049     */
050    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
051    public static class LogEntry
052        extends BaseType<LogEntry>
053        implements java.io.Serializable
054    {
055        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
056        protected static final long serialVersionUID = 1;
057
058        private static final NestedHelper<Log.LogEntry> singleton =
059            Torello.Browser.BrowserAPI.NestedHelpers.Types.
060                Log$$LogEntry$$.singleton;
061
062        /**
063         * Log entry source.
064         * <EMBED CLASS='external-html' DATA-D=Log DATA-C=LogEntry DATA-F=source DATA-FILE-ID=CDP.EL1>
065         * @see BaseType#enumStrList(String)
066         */
067        public final String source;
068
069        /**
070         * Log entry severity.
071         * <EMBED CLASS='external-html' DATA-D=Log DATA-C=LogEntry DATA-F=level DATA-FILE-ID=CDP.EL1>
072         * @see BaseType#enumStrList(String)
073         */
074        public final String level;
075
076        /** Logged text. */
077        public final String text;
078
079        /**
080         * <CODE>[No Description Provided by Google]</CODE>
081         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
082         * <EMBED CLASS='external-html' DATA-D=Log DATA-C=LogEntry DATA-F=category DATA-FILE-ID=CDP.EL1>
083         * @see BaseType#enumStrList(String)
084         */
085        public final String category;
086
087        /** Timestamp when this entry was added. */
088        public final Number timestamp;
089
090        /**
091         * URL of the resource if known.
092         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
093         */
094        public final String url;
095
096        /**
097         * Line number in the resource.
098         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
099         */
100        public final Integer lineNumber;
101
102        /**
103         * JavaScript stack trace.
104         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
105         */
106        public final RunTime.StackTrace stackTrace;
107
108        /**
109         * Identifier of the network request associated with this entry.
110         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
111         */
112        public final String networkRequestId;
113
114        /**
115         * Identifier of the worker associated with this entry.
116         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
117         */
118        public final String workerId;
119
120        /**
121         * Call arguments.
122         * <BR /><B CLASS=Opt-Top>OPTIONAL</B>
123         */
124        public final RunTime.RemoteObject[] args;
125
126        /** Constructor.  Please review this class' fields for documentation. */
127        public LogEntry(
128                ReadOnlyList<Boolean> isPresent, String source, String level, String text,
129                String category, Number timestamp, String url, Integer lineNumber,
130                RunTime.StackTrace stackTrace, String networkRequestId, String workerId,
131                RunTime.RemoteObject[] args
132            )
133        {
134            super(singleton, Domains.Log, "LogEntry", 11);
135
136            this.source             = source;
137            this.level              = level;
138            this.text               = text;
139            this.category           = category;
140            this.timestamp          = timestamp;
141            this.url                = url;
142            this.lineNumber         = lineNumber;
143            this.stackTrace         = stackTrace;
144            this.networkRequestId   = networkRequestId;
145            this.workerId           = workerId;
146            this.args               = args;
147
148            this.isPresent = (isPresent == null)
149                ? singleton.generateIsPresentList(this)
150                : THROWS.check(isPresent, 11, "Log.LogEntry");
151        }
152
153        /** Creates an instance of this class from a {@link JsonObject}.*/
154        public static LogEntry fromJSON(JsonObject jo)
155        { return singleton.fromJSON(jo); }
156
157        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
158        public static NestedDescriptor<LogEntry> descriptor()
159        { return singleton.descriptor(); }
160    }
161
162    /**
163     * Violation configuration setting.
164     * 
165     * <EMBED CLASS=globalDefs DATA-DOMAIN=Log DATA-API=BrowserAPI>
166     */
167    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI")
168    public static class ViolationSetting
169        extends BaseType<ViolationSetting>
170        implements java.io.Serializable
171    {
172        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
173        protected static final long serialVersionUID = 1;
174
175        private static final NestedHelper<Log.ViolationSetting> singleton =
176            Torello.Browser.BrowserAPI.NestedHelpers.Types.
177                Log$$ViolationSetting$$.singleton;
178
179        /**
180         * Violation type.
181         * <EMBED CLASS='external-html' DATA-D=Log DATA-C=ViolationSetting DATA-F=name DATA-FILE-ID=CDP.EL1>
182         * @see BaseType#enumStrList(String)
183         */
184        public final String name;
185
186        /** Time threshold to trigger upon. */
187        public final Number threshold;
188
189        /** Constructor.  Please review this class' fields for documentation. */
190        public ViolationSetting(ReadOnlyList<Boolean> isPresent, String name, Number threshold)
191        {
192            super(singleton, Domains.Log, "ViolationSetting", 2);
193
194            this.name       = name;
195            this.threshold  = threshold;
196
197            this.isPresent = (isPresent == null)
198                ? singleton.generateIsPresentList(this)
199                : THROWS.check(isPresent, 2, "Log.ViolationSetting");
200        }
201
202        /** Creates an instance of this class from a {@link JsonObject}.*/
203        public static ViolationSetting fromJSON(JsonObject jo)
204        { return singleton.fromJSON(jo); }
205
206        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
207        public static NestedDescriptor<ViolationSetting> descriptor()
208        { return singleton.descriptor(); }
209    }
210
211
212    // ********************************************************************************************
213    // ********************************************************************************************
214    // Event Types
215    // ********************************************************************************************
216    // ********************************************************************************************
217
218
219    /**
220     * Issued when new message was logged.
221     * 
222     * <EMBED CLASS=globalDefs DATA-DOMAIN=Log DATA-API=BrowserAPI>
223     */
224    @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI")
225    public static class entryAdded
226        extends BrowserEvent<entryAdded>
227        implements java.io.Serializable
228    {
229        /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
230        protected static final long serialVersionUID = 1;
231
232        private static final NestedHelper<Log.entryAdded> singleton =
233            Torello.Browser.BrowserAPI.NestedHelpers.Events.
234                Log$$entryAdded$$.singleton;
235
236        /** The entry. */
237        public final Log.LogEntry entry;
238
239        /** Constructor.  Please review this class' fields for documentation. */
240        public entryAdded(ReadOnlyList<Boolean> isPresent, LogEntry entry)
241        {
242            super(singleton, Domains.Log, "entryAdded", 1);
243
244            this.entry = entry;
245
246            this.isPresent = (isPresent == null)
247                ? singleton.generateIsPresentList(this)
248                : THROWS.check(isPresent, 1, "Log.entryAdded");
249        }
250
251        /** Creates an instance of this class from a {@link JsonObject}.*/
252        public static entryAdded fromJSON(JsonObject jo)
253        { return singleton.fromJSON(jo); }
254
255        /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/
256        public static NestedDescriptor<entryAdded> descriptor()
257        { return singleton.descriptor(); }
258    }
259
260
261
262
263    // ********************************************************************************************
264    // ********************************************************************************************
265    // Commands
266    // ********************************************************************************************
267    // ********************************************************************************************
268
269
270    /**
271     * Clears the log.
272     * 
273     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
274     *
275     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
276     * browser receives the invocation-request.
277     *
278     * <BR /><BR /><DIV CLASS=JDHint>
279     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
280     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
281     * the Browser Function has run to completion.
282     * </DIV>
283     */
284    public static Script<Void> clear()
285    {
286        // Ultra-Simple Request JSON - Because this method has no parameters
287        final String requestJSON = "{\"method\":\"Log.clear\"}";
288
289        return Script.NO_RET(Domains.Log, "clear", requestJSON);
290    }
291
292    /**
293     * Disables log domain, prevents further log entries from being reported to the client.
294     * 
295     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
296     *
297     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
298     * browser receives the invocation-request.
299     *
300     * <BR /><BR /><DIV CLASS=JDHint>
301     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
302     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
303     * the Browser Function has run to completion.
304     * </DIV>
305     */
306    public static Script<Void> disable()
307    {
308        // Ultra-Simple Request JSON - Because this method has no parameters
309        final String requestJSON = "{\"method\":\"Log.disable\"}";
310
311        return Script.NO_RET(Domains.Log, "disable", requestJSON);
312    }
313
314    /**
315     * Enables log domain, sends the entries collected so far to the client by means of the
316     * <CODE>entryAdded</CODE> notification.
317     * 
318     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
319     *
320     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
321     * browser receives the invocation-request.
322     *
323     * <BR /><BR /><DIV CLASS=JDHint>
324     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
325     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
326     * the Browser Function has run to completion.
327     * </DIV>
328     */
329    public static Script<Void> enable()
330    {
331        // Ultra-Simple Request JSON - Because this method has no parameters
332        final String requestJSON = "{\"method\":\"Log.enable\"}";
333
334        return Script.NO_RET(Domains.Log, "enable", requestJSON);
335    }
336
337    /**
338     * start violation reporting.
339     * 
340     * @param config Configuration for violations.
341     * 
342     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
343     *
344     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
345     * browser receives the invocation-request.
346     *
347     * <BR /><BR /><DIV CLASS=JDHint>
348     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
349     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
350     * the Browser Function has run to completion.
351     * </DIV>
352     */
353    public static Script<Void> startViolationsReport(ViolationSetting[] config)
354    {
355        // Build the JSON Request-Object (as a String); only 1 Parameter is passed
356        final String requestJSON = WriteJSON.get(
357            CDPTypes.CDP_TYPE_ARRAY_1D, "config", false, "Log.startViolationsReport", (Object)
358            config
359        );
360
361        return Script.NO_RET(Domains.Log, "startViolationsReport", requestJSON);
362    }
363
364    /**
365     * Stop violation reporting.
366     * 
367     * @return An instance of <CODE>{@link Script}&lt;Void&gt;</CODE>
368     *
369     * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the
370     * browser receives the invocation-request.
371     *
372     * <BR /><BR /><DIV CLASS=JDHint>
373     * This Browser-Function <I>does not have</I> a return-value.  You may choose to
374     * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that
375     * the Browser Function has run to completion.
376     * </DIV>
377     */
378    public static Script<Void> stopViolationsReport()
379    {
380        // Ultra-Simple Request JSON - Because this method has no parameters
381        final String requestJSON = "{\"method\":\"Log.stopViolationsReport\"}";
382
383        return Script.NO_RET(Domains.Log, "stopViolationsReport", requestJSON);
384    }
385
386
387}