Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

[FINAL] feat: [EXC-1676] add allowed viewers variant to canister's log visibility #326

Merged
merged 21 commits into from
Nov 1, 2024
Merged
1 change: 1 addition & 0 deletions spec/_attachments/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type wasm_module = blob;
type log_visibility = variant {
controllers;
public;
allowed_viewers : vec principal;
};

type canister_settings = record {
Expand Down
14 changes: 12 additions & 2 deletions spec/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,12 @@ The canister logs are *not* collected in canister methods running in non-replica
The total size of all returned logs does not exceed 4KiB.
If new logs are added resulting in exceeding the maximum total log size of 4KiB, the oldest logs will be removed.
Logs persist across canister upgrades and they are deleted if the canister is reinstalled or uninstalled.
The log visibility is defined in the `log_visibility` field of `canister_settings`: logs can be either public (visible to everyone) or only visible to the canister's controllers (by default).

The log visibility is defined in the `log_visibility` field of `canister_settings` and can be one of the following variants:

- `controllers`: only the canister's controllers can fetch logs (default);
- `public`: everyone can fetch logs;
- `allowed_viewers` (`vec principal`): only principals in the provided list and the canister's controllers can fetch logs, the maximum length of the list is 10.

A single log is a record with the following fields:

Expand Down Expand Up @@ -3267,6 +3272,7 @@ CanisterHistory = {
CanisterLogVisibility
= Controllers
| Public
| AllowedViewers [Principal]
CanisterLog = {
idx : Nat;
timestamp_nanos : Nat;
Expand Down Expand Up @@ -5902,7 +5908,11 @@ Q.canister_id = ic_principal
Q.method_name = 'fetch_canister_logs'
Q.arg = candid(A)
A.canister_id = effective_canister_id
S[A.canister_id].canister_log_visibility = Public or Q.sender in S[A.canister_id].controllers
(S[A.canister_id].canister_log_visibility = Public)
or
(S[A.canister_id].canister_log_visibility = Controllers and Q.sender in S[A.canister_id].controllers)
or
(S[A.canister_id].canister_log_visibility = AllowedViewers Principals and (Q.sender in S[A.canister_id].controllers or Q.sender in Principals))

```

Expand Down
Loading