Skip to content

feat: canister logs extensions#414

Merged
lwshang merged 19 commits intomainfrom
lwshang/log-extensions
Mar 9, 2026
Merged

feat: canister logs extensions#414
lwshang merged 19 commits intomainfrom
lwshang/log-extensions

Conversation

@lwshang
Copy link
Contributor

@lwshang lwshang commented Mar 6, 2026

Summary

  • Update to ic-agent/ic-utils 0.46 and add reqwest features
  • Add --since, --until, --since-index, --until-index filter flags to icp canister logs
  • Support log_memory_limit canister setting in icp canister settings update, icp canister settings sync, and icp canister status

Test plan

  • cargo check passes
  • Unit tests pass (cargo test -p icp-cli --bin icp)
  • Integration test on a network with Canister Logs Extensions enabled

🤖 Generated with Claude Code

lwshang and others added 9 commits March 6, 2026 13:28
- Add `json` and `stream` features to reqwest (required for
  `.json()` and `.bytes_stream()` on responses in reqwest 0.12)
- Update snapshot management calls: canister_id is now embedded in
  the args structs, removing the separate &canister_id parameter
- Add new required fields to TakeCanisterSnapshotArgs
  (uninstall_code, sender_canister_version)
- Replace removed `with_optional_*` builder methods on
  UpdateSettingsBuilder with conditional `with_*` calls
- Add log filter support in canister logs command using new
  FetchCanisterLogsArgs and CanisterLogFilter from ic-utils 0.46

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…--since-index

When only --until or --until-index is provided, default the start to 0
so users can filter logs up to a given point without specifying a start.
Also add missing conflicts_with for --follow on all filter flags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the log_memory_limit field to the Settings model, canister settings
update command, settings sync operation, and canister status display.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
aws-lc-sys (OpenSSL licensed) was pulled in via:
aws-lc-sys -> aws-lc-rs -> rustls -> hyper-rustls -> reqwest -> ic-agent

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for the Internet Computer “Canister Logs Extensions” feature across icp-cli, including new log filtering flags and the new log_memory_limit canister setting, alongside dependency upgrades needed for the updated management canister APIs.

Changes:

  • Upgrades ic-agent/ic-utils and adjusts call sites for updated management canister method signatures.
  • Extends icp canister logs with timestamp/index filtering (--since/--until/--since-index/--until-index) and follow-mode lookback behavior.
  • Adds log_memory_limit support to settings update/sync, schemas, and CLI reference docs.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/schemas/icp-yaml-schema.json Adds log_memory_limit to the ICP YAML schema.
docs/schemas/environment-yaml-schema.json Adds log_memory_limit to environment YAML schema.
docs/schemas/canister-yaml-schema.json Adds log_memory_limit to canister YAML schema and defaults.
docs/reference/cli.md Documents new canister logs filters and --log-memory-limit flag.
deny.toml Allows OpenSSL license for new/updated transitive deps.
crates/icp/src/canister/mod.rs Adds log_memory_limit to canister Settings.
crates/icp-cli/src/operations/snapshot_transfer.rs Updates snapshot transfer calls to new mgmt canister arg-based APIs.
crates/icp-cli/src/operations/settings.rs Syncs log_memory_limit and adapts update-settings builder usage.
crates/icp-cli/src/commands/canister/status.rs Displays log_memory_limit in status output.
crates/icp-cli/src/commands/canister/snapshot/create.rs Updates snapshot creation args/calls for new API fields/signatures.
crates/icp-cli/src/commands/canister/snapshot/restore.rs Updates restore call signature for new API.
crates/icp-cli/src/commands/canister/snapshot/delete.rs Updates delete call signature for new API.
crates/icp-cli/src/commands/canister/settings/update.rs Adds --log-memory-limit and wires it into settings updates.
crates/icp-cli/src/commands/canister/logs.rs Adds filtering flags, filter construction, timestamp parsing, and tests.
Cargo.toml Bumps IC crates and enables additional reqwest features.
Cargo.lock Locks updated dependency graph for new crate versions.
CHANGELOG.md Notes new logs filtering and log_memory_limit support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

lwshang and others added 3 commits March 6, 2026 15:45
… logs

- Use unix_timestamp_nanos() instead of manual arithmetic in parse_timestamp
  to prevent silent overflow/wrapping for pre-epoch or far-future timestamps
- Validate that --since/--until and --since-index/--until-index ranges are
  not inverted, returning a clear error instead of empty or confusing results

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add unit tests for build_filter and parse_timestamp edge cases, integration
tests for --since-index/--until-index and --since/--until filtering, unit
tests for log_memory_limit suffix parsing, and a comment explaining why
log_memory_limit is not covered in canister_settings_tests (PocketIC
does not yet support it).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

lwshang and others added 7 commits March 6, 2026 21:31
- Use 0-based message names to match 0-based log indices
- Fix --since timestamp to use valid u64 value (was overflowing)
- Document expected --until-index inclusive behavior vs current
  PocketIC exclusive implementation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `--until` and `--until-index` flags use exclusive upper bounds,
not inclusive. Update help text, error messages, validation (reject
equal bounds), and tests to reflect this.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
A purely numeric timestamp exceeding u64 range now gets a clear
"overflows the nanosecond timestamp range" error instead of the
misleading "not a valid … or RFC3339 datetime" message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…uncation

Replace `as u64` cast with `u64::try_from().ok()` when computing
now_nanos in follow mode, falling back to 0 on overflow. Also
applies rustfmt formatting fixes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update reqwest to 0.13.2 and rename the `rustls-tls` feature to
`rustls` to match the new API. This also removes unused transitive
dependencies (webpki-roots, wasm-streams 0.4, ring).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When only --until-index 0 or --until 0 is passed, the previous error
misleadingly showed both start and end as 0. Now these cases get a
dedicated message explaining the exclusive end bound.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Include log_memory_limit in the miscellaneous settings update test so
that when PocketIC gains support for the field, the now-expected 0 will
fail and remind us to update the assertion to the correct value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lwshang lwshang marked this pull request as ready for review March 9, 2026 16:06
@lwshang lwshang requested a review from a team as a code owner March 9, 2026 16:06
@lwshang lwshang merged commit f339db6 into main Mar 9, 2026
89 checks passed
@lwshang lwshang deleted the lwshang/log-extensions branch March 9, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants