Skip to main content

cdp_driver/protocol/
log.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! Provides access to log entries.
5//!
6//! Types, command parameters and event payloads for the `Log`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9
10use serde::{Deserialize, Serialize};
11
12/// Log entry.
13#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
14pub struct LogEntry {
15    /// Log entry source.
16    pub source: LogEntrySource,
17    /// Log entry severity.
18    pub level: LogEntryLevel,
19    /// Logged text.
20    pub text: String,
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub category: Option<LogEntryCategory>,
23    /// Timestamp when this entry was added.
24    pub timestamp: crate::protocol::runtime::Timestamp,
25    /// URL of the resource if known.
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub url: Option<String>,
28    /// Line number in the resource.
29    #[serde(
30        rename = "lineNumber",
31        default,
32        skip_serializing_if = "Option::is_none"
33    )]
34    pub line_number: Option<i64>,
35    /// JavaScript stack trace.
36    #[serde(
37        rename = "stackTrace",
38        default,
39        skip_serializing_if = "Option::is_none"
40    )]
41    pub stack_trace: Option<crate::protocol::runtime::StackTrace>,
42    /// Identifier of the network request associated with this entry.
43    #[serde(
44        rename = "networkRequestId",
45        default,
46        skip_serializing_if = "Option::is_none"
47    )]
48    pub network_request_id: Option<crate::protocol::network::RequestId>,
49    /// Identifier of the worker associated with this entry.
50    #[serde(rename = "workerId", default, skip_serializing_if = "Option::is_none")]
51    pub worker_id: Option<String>,
52    /// Call arguments.
53    #[serde(default, skip_serializing_if = "Option::is_none")]
54    pub args: Option<Vec<crate::protocol::runtime::RemoteObject>>,
55}
56
57/// The values `source` accepts on `LogEntry`.
58#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
59pub enum LogEntrySource {
60    /// `xml`
61    #[serde(rename = "xml")]
62    Xml,
63    /// `javascript`
64    #[serde(rename = "javascript")]
65    Javascript,
66    /// `network`
67    #[serde(rename = "network")]
68    Network,
69    /// `storage`
70    #[serde(rename = "storage")]
71    Storage,
72    /// `appcache`
73    #[serde(rename = "appcache")]
74    Appcache,
75    /// `rendering`
76    #[serde(rename = "rendering")]
77    Rendering,
78    /// `security`
79    #[serde(rename = "security")]
80    Security,
81    /// `deprecation`
82    #[serde(rename = "deprecation")]
83    Deprecation,
84    /// `worker`
85    #[serde(rename = "worker")]
86    Worker,
87    /// `violation`
88    #[serde(rename = "violation")]
89    Violation,
90    /// `intervention`
91    #[serde(rename = "intervention")]
92    Intervention,
93    /// `recommendation`
94    #[serde(rename = "recommendation")]
95    Recommendation,
96    /// `other`
97    #[serde(rename = "other")]
98    Other,
99    /// A value this vendored schema does not list. Chrome adds values ahead of
100    /// the published protocol, so an unrecognised one is kept as it arrived
101    /// rather than failing the payload it came in.
102    #[serde(untagged)]
103    Unrecognized(String),
104}
105
106/// The values `level` accepts on `LogEntry`.
107#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
108pub enum LogEntryLevel {
109    /// `verbose`
110    #[serde(rename = "verbose")]
111    Verbose,
112    /// `info`
113    #[serde(rename = "info")]
114    Info,
115    /// `warning`
116    #[serde(rename = "warning")]
117    Warning,
118    /// `error`
119    #[serde(rename = "error")]
120    Error,
121    /// A value this vendored schema does not list. Chrome adds values ahead of
122    /// the published protocol, so an unrecognised one is kept as it arrived
123    /// rather than failing the payload it came in.
124    #[serde(untagged)]
125    Unrecognized(String),
126}
127
128/// The values `category` accepts on `LogEntry`.
129#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
130pub enum LogEntryCategory {
131    /// `cors`
132    #[serde(rename = "cors")]
133    Cors,
134    /// A value this vendored schema does not list. Chrome adds values ahead of
135    /// the published protocol, so an unrecognised one is kept as it arrived
136    /// rather than failing the payload it came in.
137    #[serde(untagged)]
138    Unrecognized(String),
139}
140
141/// Violation configuration setting.
142#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
143pub struct ViolationSetting {
144    /// Violation type.
145    pub name: ViolationSettingName,
146    /// Time threshold to trigger upon.
147    pub threshold: f64,
148}
149
150/// The values `name` accepts on `ViolationSetting`.
151#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
152pub enum ViolationSettingName {
153    /// `longTask`
154    #[serde(rename = "longTask")]
155    LongTask,
156    /// `longLayout`
157    #[serde(rename = "longLayout")]
158    LongLayout,
159    /// `blockedEvent`
160    #[serde(rename = "blockedEvent")]
161    BlockedEvent,
162    /// `blockedParser`
163    #[serde(rename = "blockedParser")]
164    BlockedParser,
165    /// `discouragedAPIUse`
166    #[serde(rename = "discouragedAPIUse")]
167    DiscouragedApiUse,
168    /// `handler`
169    #[serde(rename = "handler")]
170    Handler,
171    /// `recurringHandler`
172    #[serde(rename = "recurringHandler")]
173    RecurringHandler,
174    /// A value this vendored schema does not list. Chrome adds values ahead of
175    /// the published protocol, so an unrecognised one is kept as it arrived
176    /// rather than failing the payload it came in.
177    #[serde(untagged)]
178    Unrecognized(String),
179}
180
181/// Clears the log.
182///
183/// Parameters of `Log.clear`.
184#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
185pub struct ClearParams {}
186
187impl crate::typed::Command for ClearParams {
188    const METHOD: &'static str = "Log.clear";
189    type Returns = crate::typed::NoReturns;
190}
191
192/// Disables log domain, prevents further log entries from being reported to
193/// the client.
194///
195/// Parameters of `Log.disable`.
196#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
197pub struct DisableParams {}
198
199impl crate::typed::Command for DisableParams {
200    const METHOD: &'static str = "Log.disable";
201    type Returns = crate::typed::NoReturns;
202}
203
204/// Enables log domain, sends the entries collected so far to the client by
205/// means of the `entryAdded` notification.
206///
207/// Parameters of `Log.enable`.
208#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
209pub struct EnableParams {}
210
211impl crate::typed::Command for EnableParams {
212    const METHOD: &'static str = "Log.enable";
213    type Returns = crate::typed::NoReturns;
214}
215
216/// start violation reporting.
217///
218/// Parameters of `Log.startViolationsReport`.
219#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
220pub struct StartViolationsReportParams {
221    /// Configuration for violations.
222    pub config: Vec<ViolationSetting>,
223}
224
225impl crate::typed::Command for StartViolationsReportParams {
226    const METHOD: &'static str = "Log.startViolationsReport";
227    type Returns = crate::typed::NoReturns;
228}
229
230/// Stop violation reporting.
231///
232/// Parameters of `Log.stopViolationsReport`.
233#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
234pub struct StopViolationsReportParams {}
235
236impl crate::typed::Command for StopViolationsReportParams {
237    const METHOD: &'static str = "Log.stopViolationsReport";
238    type Returns = crate::typed::NoReturns;
239}
240
241/// Issued when new message was logged.
242///
243/// Payload of the `Log.entryAdded` event.
244#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
245pub struct EntryAddedEvent {
246    /// The entry.
247    pub entry: LogEntry,
248}
249
250impl crate::typed::Event for EntryAddedEvent {
251    const METHOD: &'static str = "Log.entryAdded";
252}