wasmer_deploy_schema/schema/
logging.rs

1use serde::{Deserialize, Serialize};
2
3use super::Merge;
4
5/// Configure log capturing.
6#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, Default, schemars::JsonSchema)]
7pub struct CapabilityLoggingV1 {
8    /// Enable log capture.
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub enabled: Option<bool>,
11
12    /// Capture the stdout stream.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub capture_stdout: Option<bool>,
15
16    /// Capture the stderr stream.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub capture_stderr: Option<bool>,
19
20    /// Capture trap information.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub capture_trap: Option<bool>,
23}
24
25impl CapabilityLoggingV1 {
26    pub fn enabled(&self) -> bool {
27        self.enabled.unwrap_or_default()
28    }
29
30    pub fn capture_stdout(&self) -> bool {
31        self.capture_stdout.unwrap_or_default()
32    }
33
34    pub fn capture_stderr(&self) -> bool {
35        self.capture_stderr.unwrap_or_default()
36    }
37
38    pub fn capture_trap(&self) -> bool {
39        self.capture_trap.unwrap_or_default()
40    }
41}
42
43impl Merge for CapabilityLoggingV1 {
44    fn merge_extend(self, other: &Self) -> Self {
45        Self {
46            enabled: self.enabled.merge_extend(&other.enabled),
47            capture_stdout: self.capture_stdout.merge_extend(&other.capture_stdout),
48            capture_stderr: self.capture_stderr.merge_extend(&other.capture_stderr),
49            capture_trap: self.capture_trap.merge_extend(&other.capture_trap),
50        }
51    }
52}