From 44c593e1e765d432a1f6ffe5c8bb2f11e9a87e8d Mon Sep 17 00:00:00 2001
From: Severin Siffert <severin.siffert@dfinity.org>
Date: Thu, 27 Jun 2024 22:50:54 +0200
Subject: [PATCH] feat: support log_visibility canister setting (#497)

---
 main/types.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/main/types.rs b/main/types.rs
index ac185fa0193..97c284fd348 100644
--- a/main/types.rs
+++ b/main/types.rs
@@ -4,6 +4,20 @@ use serde::{Deserialize, Serialize};
 /// Canister ID is Principal.
 pub type CanisterId = Principal;
 
+/// todo
+#[derive(
+    CandidType, Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default,
+)]
+pub enum LogVisibility {
+    #[default]
+    #[serde(rename = "controllers")]
+    /// Only controllers of the canister can access the logs.
+    Controllers,
+    #[serde(rename = "public")]
+    /// Everyone is allowed to access the canister's logs.
+    Public,
+}
+
 /// Canister settings.
 ///
 /// The settings are optional. If they are not explicitly set, the default values will be applied automatically.
@@ -52,6 +66,10 @@ pub struct CanisterSettings {
     ///
     /// Default value: 5_000_000_000_000 (5 trillion cycles).
     pub reserved_cycles_limit: Option<Nat>,
+    /// Defines who is allowed to read the canister's logs.
+    ///
+    /// Default value: Controllers
+    pub log_visibility: Option<LogVisibility>,
     /// Must be a number between 0 and 2<sup>48</sup>-1 (i.e 256TB), inclusively.
     ///
     /// It indicates the upper limit on the WASM heap memory consumption of the canister.
@@ -317,6 +335,8 @@ pub struct DefiniteCanisterSettings {
     pub freezing_threshold: Nat,
     /// Reserved cycles limit.
     pub reserved_cycles_limit: Nat,
+    /// Visibility of canister logs.
+    pub log_visibility: LogVisibility,
     /// The Wasm memory limit.
     pub wasm_memory_limit: Nat,
 }