diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ed94b1a3e..2282c4f222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ `dfx start --pocketic` is now compatible with `--artificial-delay` and the `subnet_type` configuration option, and enables `--enable-canister-http` by default. +### feat: Support canister log allowed viewer list + +Added support for the canister log allowed viewer list, which configures which users are allowed to read a canister's logs, with no need to be set as controller of the canister. +Valid settings are: +- `--add-log-viewer`, `--remove-log-viewer` and `--set-log-viewer` flags with `dfx canister update-settings` +- `--log-viewer` flag with `dfx canister create` +- `canisters[].initialization_values.log_visibility.allowed_viewers` in `dfx.json` + ## Dependencies ### Replica diff --git a/docs/cli-reference/dfx-canister.mdx b/docs/cli-reference/dfx-canister.mdx index 39e606227a..9f836d8f1e 100644 --- a/docs/cli-reference/dfx-canister.mdx +++ b/docs/cli-reference/dfx-canister.mdx @@ -280,6 +280,7 @@ You can use the following options with the `dfx canister create` command. | `--memory-allocation ` | Specifies how much memory the canister is allowed to use in total. This should be a value in the range [0..12 GiB]. A setting of 0 means the canister will have access to memory on a “best-effort” basis: It will only be charged for the memory it uses, but at any point in time may stop running if it tries to allocate more memory when there isn’t space available on the subnet. | | `--reserved-cycles-limit ` | Specifies the upper limit for the canister's reserved cycles. | | `--wasm-memory-limit ` | Specifies a soft upper limit for the canister's heap memory. | +| `--log-viewer ` | Specifies the the principal of the log viewer of the canister. Can be specified more than once. | | `--log-visibility ` | Specifies who is allowed to read the canister's logs. Can be either "controllers" or "public". | | `--no-wallet` | Performs the call with the user Identity as the Sender of messages. Bypasses the Wallet canister. Enabled by default. | | `--with-cycles ` | Specifies the initial cycle balance to deposit into the newly created canister. The specified amount needs to take the canister create fee into account. This amount is deducted from the wallet's cycle balance. | @@ -1137,14 +1138,17 @@ You can specify the following options for the `dfx canister update-settings` com | Option | Description | |-------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `--add-controller ` | Add a principal to the list of controllers of the canister. | +| `--add-log-viewer ` | Add a principal to the list of log viewers of the canister. | | `-c`, `--compute-allocation ` | Specifies the canister's compute allocation. This should be a percent in the range [0..100]. | | `--confirm-very-long-freezing-threshold` | Freezing thresholds above ~1.5 years require this option as confirmation. | | `--set-controller ` | Specifies the identity name or the principal of the new controller. Can be specified more than once, indicating the canister will have multiple controllers. If any controllers are set with this parameter, any other controllers will be removed. | +| `--set-log-viewer ` | Specifies the the principal of the log viewer of the canister. Can be specified more than once, indicating the canister will have multiple log viewers. If any log viewers are set with this parameter, any other log viewers will be removed. | | `--memory-allocation ` | Specifies how much memory the canister is allowed to use in total. This should be a value in the range [0..12 GiB]. A setting of 0 means the canister will have access to memory on a “best-effort” basis: It will only be charged for the memory it uses, but at any point in time may stop running if it tries to allocate more memory when there isn’t space available on the subnet. | | `--reserved-cycles-limit ` | Specifies the upper limit of the canister's reserved cycles. | | `--wasm-memory-limit ` | Specifies a soft upper limit for the canister's heap memory. | | `--log-visibility ` | Specifies who is allowed to read the canister's logs. Can be either "controllers" or "public". | | `--remove-controller ` | Removes a principal from the list of controllers of the canister. | +| `--remove-log-viewer ` | Removes a principal from the list of log viewers of the canister. | | `--freezing-threshold ` | Set the [freezing threshold](https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-create_canister) in seconds for a canister. This should be a value in the range [0..2^64^-1]. Very long thresholds require the `--confirm-very-long-freezing-threshold` option. | | `-y`, `--yes` | Skips yes/no checks by answering 'yes'. Such checks can result in loss of control, so this is not recommended outside of CI. | diff --git a/src/dfx/src/commands/canister/create.rs b/src/dfx/src/commands/canister/create.rs index 7eb53b75f6..88687d4c4c 100644 --- a/src/dfx/src/commands/canister/create.rs +++ b/src/dfx/src/commands/canister/create.rs @@ -96,7 +96,8 @@ pub struct CanisterCreateOpts { #[arg(long, value_parser = log_visibility_parser, conflicts_with("log_viewer"))] log_visibility: Option, - /// Specifies the identity name or the principal of the new controller. + /// Specifies the the principal of the log viewer of the canister. + /// Can be specified more than once. #[arg(long, action = ArgAction::Append, conflicts_with("log_visibility"))] log_viewer: Option>, diff --git a/src/dfx/src/lib/canister_logs/log_visibility.rs b/src/dfx/src/lib/canister_logs/log_visibility.rs index 538ee6b07e..566d376dd5 100644 --- a/src/dfx/src/lib/canister_logs/log_visibility.rs +++ b/src/dfx/src/lib/canister_logs/log_visibility.rs @@ -24,11 +24,11 @@ pub struct LogVisibilityOpt { #[arg(long, action = ArgAction::Append, conflicts_with("set_log_viewer"))] add_log_viewer: Option>, - /// Remove a principal from the list of log viewers of the canister. + /// Removes a principal from the list of log viewers of the canister. #[arg(long, action = ArgAction::Append, conflicts_with("set_log_viewer"))] remove_log_viewer: Option>, - /// Specifies the the principal of the log viewers of the canister. + /// Specifies the the principal of the log viewer of the canister. /// Can be specified more than once. #[arg( long,