Skip to content

Commit b3e76aa

Browse files
committed
docs(logs): address PR feedback on canister logs extensions
1 parent 6c78fad commit b3e76aa

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

docs/references/ic-interface-spec/abstract-behavior.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4236,7 +4236,7 @@ S with
42364236

42374237
#### Canister out of cycles
42384238

4239-
Once a canister runs out of cycles, its code is uninstalled (cf. [IC Management Canister: Code uninstallation](#rule-uninstall)), the canister changes in the canister history are dropped (their total number is preserved), and the allocations are set to zero:
4239+
Once a canister runs out of cycles, its code is uninstalled (cf. [IC Management Canister: Code uninstallation](#rule-uninstall)), the canister changes in the canister history are dropped (their total number is preserved), and the allocations and the canister log memory limit are set to zero:
42404240

42414241
Conditions
42424242

docs/references/ic-interface-spec/management-canister.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ A snapshot may be deleted only by the controllers of the canister that the snaps
960960

961961
### IC method `fetch_canister_logs` {#ic-fetch_canister_logs}
962962

963-
This method can be called by canisters via replicated calls, i.e., it cannot be called by external users via replicated (update) calls.
963+
This method can be called by canisters via replicated calls, but it cannot be called by external users via replicated (update) calls.
964964
This method can also be called via non-replicated (query) calls: by external users directly and by canisters from composite query methods and their callbacks.
965965
A call from a composite query is executed against the state of the subnet hosting the calling canister and can thus only target canisters hosted by that subnet.
966966

@@ -982,7 +982,7 @@ A single log is a record with the following fields:
982982
- `timestamp_nanos` (`nat64`): the timestamp as nanoseconds since 1970-01-01 at which the log was recorded;
983983
- `content` (`blob`): the actual content of the log;
984984

985-
To filter canister logs, an optional filter can be provided and have one of the following variants:
985+
To filter canister logs, an optional filter can be provided and has one of the following variants:
986986
- `by_idx` (`record { start : nat64; end : nat64 }`): only logs are returned whose `idx` is within the provided range (`start` is inclusive, but `end` is exclusive);
987987
- `by_timestamp_nanos` (`record { start : nat64; end : nat64 }`): only logs are returned whose `timestamp_nanos` is within the provided range (`start` is inclusive, but `end` is exclusive).
988988

docs/references/management-canister.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Several methods accept or return a `canister_settings` record. The fields are:
2727
| `wasm_memory_limit` | `nat` | `0` | Upper limit on Wasm heap memory in bytes (0 = no limit) |
2828
| `wasm_memory_threshold` | `nat` | `0` | Remaining Wasm memory threshold that triggers the low-memory hook |
2929
| `log_visibility` | `log_visibility` | `controllers` | Who can read canister logs: `controllers`, `public`, or `allowed_viewers(vec principal)` |
30+
| `log_memory_limit` | `nat` | `4096` | Memory in bytes for storing canister logs: either `0` or between `4096` and `2097152` (2 MiB) |
3031
| `snapshot_visibility` | `snapshot_visibility` | `controllers` | Who can list and read canister snapshots: `controllers`, `public`, or `allowed_viewers(vec principal)` |
3132
| `status_visibility` | `status_visibility` | `controllers` | Who can read the canister status: `controllers`, `public`, or `allowed_viewers(vec principal)` |
3233
| `environment_variables` | `opt record` | `null` | Key-value pairs accessible during canister execution |
@@ -129,7 +130,7 @@ Returns detailed information about a canister: status, settings, module hash, cy
129130
- `settings`: the definite canister settings currently in effect
130131
- `module_hash` (`opt blob`): SHA-256 of installed module (`null` if empty)
131132
- `memory_size` (`nat`): total memory consumed
132-
- `memory_metrics`: breakdown by component (Wasm memory, stable memory, globals, binary, custom sections, history, chunk store, snapshots)
133+
- `memory_metrics`: breakdown by component (Wasm memory, stable memory, globals, binary, custom sections, history, chunk store, snapshots, log memory store)
133134
- `cycles` (`nat`): current cycle balance
134135
- `reserved_cycles` (`nat`): reserved cycle balance
135136
- `idle_cycles_burned_per_day` (`nat`): daily idle burn rate
@@ -534,13 +535,17 @@ For Bitcoin integration patterns, see the [Bitcoin guide](../guides/chain-fusion
534535

535536
### `fetch_canister_logs`
536537

537-
Returns the most recent log entries for a canister. Logs are produced by `ic0.debug_print` and trap messages. Logs persist across upgrades but are purged on reinstall or uninstall. Total log size is capped at 4 KiB.
538+
Returns log entries for a canister. Logs are produced by `ic0.debug_print` and trap messages. Logs persist across upgrades but are purged on reinstall or uninstall. The oldest logs are purged once the memory used for canister logs exceeds the `log_memory_limit` canister setting.
538539

539-
- **Caller:** External users via query calls, or canisters from composite queries (not callable via replicated calls)
540-
- **Parameters:** `canister_id` (`principal`)
540+
- **Caller:** Canisters via replicated calls or composite queries, and external users via query calls (external users cannot call it via replicated calls)
541+
- **Parameters:**
542+
- `canister_id` (`principal`)
543+
- `filter` (`opt variant { by_idx : record { start : nat64; end : nat64 }; by_timestamp_nanos : record { start : nat64; end : nat64 } }`): returns only the logs whose `idx` or `timestamp_nanos` falls in the given range (`start` is inclusive, `end` is exclusive)
541544
- **Returns:**
542545
- `canister_log_records` (`vec record { idx : nat64; timestamp_nanos : nat64; content : blob }`)
543546

547+
The total size of the returned logs is bounded by an implementation-defined constant chosen so as not to exceed the maximum response size. When the selected logs do not all fit, an unfiltered read trims the oldest records, so the response ends with the newest log, and a filtered read trims the newest records, so the response starts with the oldest log matching the filter.
548+
544549
Log visibility is controlled by the `log_visibility` canister setting.
545550

546551
For practical usage, see the [canister logs guide](../guides/canister-management/logs.md).

public/references/ic.did

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ type fetch_canister_logs_args = record {
515515
filter : opt variant {
516516
by_idx : record { start : nat64; end : nat64 };
517517
by_timestamp_nanos : record { start : nat64; end : nat64 };
518-
}
518+
};
519519
};
520520

521521
type canister_log_record = record {

0 commit comments

Comments
 (0)