Skip to main content

browser_protocol/log/
mod.rs

1//! Provides access to log entries.
2use serde::{Serialize, Deserialize};
3use serde_json::Value as JsonValue;
4
5/// Log entry.
6
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct LogEntry {
10    /// Log entry source.
11
12    pub source: String,
13    /// Log entry severity.
14
15    pub level: String,
16    /// Logged text.
17
18    pub text: String,
19
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub category: Option<String>,
22    /// Timestamp when this entry was added.
23
24    pub timestamp: crate::runtime::Timestamp,
25    /// URL of the resource if known.
26
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub url: Option<String>,
29    /// Line number in the resource.
30
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub lineNumber: Option<i64>,
33    /// JavaScript stack trace.
34
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub stackTrace: Option<crate::runtime::StackTrace>,
37    /// Identifier of the network request associated with this entry.
38
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub networkRequestId: Option<crate::network::RequestId>,
41    /// Identifier of the worker associated with this entry.
42
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub workerId: Option<String>,
45    /// Call arguments.
46
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub args: Option<Vec<crate::runtime::RemoteObject>>,
49}
50
51/// Violation configuration setting.
52
53#[derive(Debug, Clone, Serialize, Deserialize, Default)]
54#[serde(rename_all = "camelCase")]
55pub struct ViolationSetting {
56    /// Violation type.
57
58    pub name: String,
59    /// Time threshold to trigger upon.
60
61    pub threshold: f64,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize, Default)]
65pub struct ClearParams {}
66
67impl ClearParams { pub const METHOD: &'static str = "Log.clear"; }
68
69impl crate::CdpCommand for ClearParams {
70    const METHOD: &'static str = "Log.clear";
71    type Response = crate::EmptyReturns;
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize, Default)]
75pub struct DisableParams {}
76
77impl DisableParams { pub const METHOD: &'static str = "Log.disable"; }
78
79impl crate::CdpCommand for DisableParams {
80    const METHOD: &'static str = "Log.disable";
81    type Response = crate::EmptyReturns;
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize, Default)]
85pub struct EnableParams {}
86
87impl EnableParams { pub const METHOD: &'static str = "Log.enable"; }
88
89impl crate::CdpCommand for EnableParams {
90    const METHOD: &'static str = "Log.enable";
91    type Response = crate::EmptyReturns;
92}
93
94/// start violation reporting.
95
96#[derive(Debug, Clone, Serialize, Deserialize, Default)]
97#[serde(rename_all = "camelCase")]
98pub struct StartViolationsReportParams {
99    /// Configuration for violations.
100
101    pub config: Vec<ViolationSetting>,
102}
103
104impl StartViolationsReportParams { pub const METHOD: &'static str = "Log.startViolationsReport"; }
105
106impl crate::CdpCommand for StartViolationsReportParams {
107    const METHOD: &'static str = "Log.startViolationsReport";
108    type Response = crate::EmptyReturns;
109}
110
111#[derive(Debug, Clone, Serialize, Deserialize, Default)]
112pub struct StopViolationsReportParams {}
113
114impl StopViolationsReportParams { pub const METHOD: &'static str = "Log.stopViolationsReport"; }
115
116impl crate::CdpCommand for StopViolationsReportParams {
117    const METHOD: &'static str = "Log.stopViolationsReport";
118    type Response = crate::EmptyReturns;
119}