Skip to content

feat: add func logs command to stream function logs#3669

Merged
knative-prow[bot] merged 2 commits into
knative:mainfrom
Itx-Psycho0:feature/3521-add-func-logs-command
May 16, 2026
Merged

feat: add func logs command to stream function logs#3669
knative-prow[bot] merged 2 commits into
knative:mainfrom
Itx-Psycho0:feature/3521-add-func-logs-command

Conversation

@Itx-Psycho0
Copy link
Copy Markdown
Contributor

This PR implements the func logs command requested in issue #3521.

The command provides a simple way to stream logs from deployed functions without needing to know the underlying service name or pod details.

Usage examples:

  • Stream logs from current directory: func logs
  • Stream logs by name: func logs --name my-function
  • Filter by time: func logs --since 5m
  • Custom namespace: func logs --namespace my-ns

Implementation details:

  • Uses the existing GetKServiceLogs functionality from the knative package
  • Supports graceful shutdown with Ctrl+C
  • Includes comprehensive tests
  • All tests and linting checks pass

The command is added to the Development Commands group alongside run, invoke, and build commands.

Fixes #3521

This adds a new 'func logs' command that streams logs from deployed functions,
abstracting away the underlying service name and pod details.

Features:
- Stream logs for function in current directory
- Stream logs by function name with --name flag
- Filter logs by time with --since flag (e.g., 5m, 1h)
- Support for custom namespace with --namespace flag
- Graceful handling of Ctrl+C to stop log streaming

The command uses the existing GetKServiceLogs functionality from the knative
package, providing a user-friendly CLI interface for developers.

Fixes knative#3521
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 7, 2026 12:49
@knative-prow knative-prow Bot added size/L 🤖 PR changes 100-499 lines, ignoring generated files. needs-ok-to-test 🤖 Needs an org member to approve testing labels May 7, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 7, 2026

Hi @Itx-Psycho0. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Itx-Psycho0
Copy link
Copy Markdown
Contributor Author

Hi @lkingland @jrangelramos,

I've implemented the func logs command as discussed in this issue. The implementation uses the Kubernetes logs API approach as suggested by @srikaryt2.

The command provides a clean interface for streaming function logs without requiring users to know service names or pod details. It supports filtering by time and works with both local functions and functions specified by name.

All tests pass and the implementation follows the existing command patterns in the codebase.

Looking forward to your feedback.

Thanks!

@matejvasek matejvasek requested review from gauron99 and lkingland and removed request for dsimansk and jrangelramos May 7, 2026 22:32
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 29.31034% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.47%. Comparing base (33a9d85) to head (6e9495b).
⚠️ Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
cmd/logs.go 28.69% 80 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3669      +/-   ##
==========================================
- Coverage   56.61%   56.47%   -0.14%     
==========================================
  Files         181      182       +1     
  Lines       20853    20969     +116     
==========================================
+ Hits        11806    11843      +37     
- Misses       7833     7911      +78     
- Partials     1214     1215       +1     
Flag Coverage Δ
e2e 36.20% <29.31%> (-0.06%) ⬇️
e2e go 32.90% <31.52%> (-0.01%) ⬇️
e2e node 28.63% <31.52%> (+0.01%) ⬆️
e2e python 33.27% <31.52%> (-0.02%) ⬇️
e2e quarkus 28.78% <31.52%> (+0.01%) ⬆️
e2e rust 28.18% <31.52%> (+0.02%) ⬆️
e2e springboot 26.66% <31.52%> (+0.03%) ⬆️
e2e typescript 28.74% <31.52%> (+0.01%) ⬆️
e2e-config-ci 18.06% <31.52%> (+0.08%) ⬆️
integration 17.24% <0.00%> (-0.08%) ⬇️
unit macos-14 44.58% <31.52%> (-0.08%) ⬇️
unit macos-latest 44.58% <31.52%> (-0.08%) ⬇️
unit ubuntu-24.04-arm 44.82% <29.31%> (-0.09%) ⬇️
unit ubuntu-latest 45.43% <31.52%> (-0.08%) ⬇️
unit windows-latest 44.56% <31.52%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lkingland
Copy link
Copy Markdown
Member

/ok-to-test
/lgtm
/approve

Thanks for the PR!

@knative-prow knative-prow Bot added ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. lgtm 🤖 PR is ready to be merged. and removed needs-ok-to-test 🤖 Needs an org member to approve testing labels May 16, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Itx-Psycho0, lkingland

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label May 16, 2026
@knative-prow knative-prow Bot merged commit 7aecae7 into knative:main May 16, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. lgtm 🤖 PR is ready to be merged. ok-to-test 🤖 Non-member PR verified by an org member that is safe to test. size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add func logs command

2 participants