Skip to content

Add base44 logs command for fetching function runtime logs#225

Merged
kfirstri merged 10 commits intomainfrom
function-logs-command
Feb 22, 2026
Merged

Add base44 logs command for fetching function runtime logs#225
kfirstri merged 10 commits intomainfrom
function-logs-command

Conversation

@ozsay
Copy link
Contributor

@ozsay ozsay commented Feb 10, 2026

Note

Description

This PR adds a base44 logs command that fetches runtime logs for deployed functions from the Base44 backend. The command supports filtering by function name(s), time range, log level, result limit, and sort order, and can output either human-readable text or raw JSON for piping. It also normalizes Python KeyError backend responses to HTTP 404 so the CLI can surface helpful "function not found" error messages.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • src/cli/commands/project/logs.ts — New logs command implementation with support for --function, --since, --until, --limit, --order, and --json flags; fetches logs for all project functions when no --function is specified, and merges/sorts results when multiple functions are queried
  • src/core/resources/function/api.ts — New fetchFunctionLogs() API function that calls GET functions-mgmt/{name}/logs with query-string filters, validated via Zod
  • src/core/resources/function/schema.ts — New Zod schemas and TypeScript types for FunctionLogEntry, FunctionLogsResponse, and FunctionLogFilters
  • src/core/errors.tsApiError.fromHttpError() now normalizes backend KeyError responses to 404 status to enable accurate "not found" error handling
  • src/cli/utils/runCommand.ts — Added stdout field to RunCommandResult so commands can write pipeable/machine-readable output after the clack UI finishes; also removed the extra leading blank line from runCommand
  • src/cli/program.ts — Registers the new logs command
  • tests/cli/logs.spec.ts — Full integration test suite covering single/multi-function fetch, all-functions fallback, empty results, --json output, invalid options, and API error handling
  • tests/cli/testkit/Base44APIMock.ts — Added mockFunctionLogs() and mockFunctionLogsError() helpers to the API mock
  • README.md — Added logs entry to the commands table

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

When multiple functions are queried together, each function's logs are fetched in parallel (one request per function) and the results are merge-sorted client-side by timestamp. The --limit option is applied after merging so the total result count respects the cap across all functions. The stdout field added to RunCommandResult is a general-purpose mechanism that any future command needing pipeable output can reuse.


🤖 Generated by Claude | 2026-02-22 00:00 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.33-pr.225.3509af6

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.33-pr.225.3509af6"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.33-pr.225.3509af6"
  }
}

Preview published to npm registry — try new features instantly!

@claude
Copy link

claude bot commented Feb 10, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@claude
Copy link

claude bot commented Feb 10, 2026

Found 2 issues:

  1. FunctionNotFoundError should be in errors.ts per CLAUDE.md
  2. normalizeDatetime regex needs anchor on Z

See full details in review comment.

@claude
Copy link

claude bot commented Feb 10, 2026

Code Review - Detailed Findings

Issue 1: FunctionNotFoundError location violates CLAUDE.md

File: src/core/resources/function/api.ts (lines 11-38)

Problem: The PR defines FunctionNotFoundError in src/core/resources/function/api.ts, but CLAUDE.md requires all error classes to be in src/core/errors.ts.

References:

  • Line 479: "Import errors from @/core/errors.js"
  • Rule fix folders issues #15 (line 659): "use specific error classes from @/core/errors.js"

See: https://github.com/base44/cli/blob/4f5dea819eb329ccb12bab118fedb262623aae0b/CLAUDE.md#L479

Solution: Move FunctionNotFoundError to src/core/errors.ts and import it from @/core/errors.js


Issue 2: Regex bug in normalizeDatetime

File: src/cli/commands/logs/index.ts (lines 88-91)

Problem: The regex /Z|[+-]\d{2}:\d{2}$/ matches Z anywhere (not just at end) due to alternation precedence.

Current: if (/Z|[+-]\d{2}:\d{2}$/.test(value))

Fixed: if (/Z$|[+-]\d{2}:\d{2}$/.test(value))

Impact: Minimal in practice, but technically incorrect.


Otherwise excellent work! Well-structured implementation with comprehensive tests.

…alizeDatetime

- Move FunctionNotFoundError class to core/errors.ts per project conventions
- Fix regex alternation bug: anchor Z to end-of-string in normalizeDatetime

Co-authored-by: Cursor <cursoragent@cursor.com>
@kfirstri kfirstri moved this from Backlog to In progress in CLI Development Feb 12, 2026
@claude
Copy link

claude bot commented Feb 22, 2026

README check ran. 1 issue found and applied: added missing logs command to the command table. README.md has been updated in this branch.

@claude claude bot force-pushed the function-logs-command branch from cbeef0e to deb9871 Compare February 22, 2026 13:04
@claude
Copy link

claude bot commented Feb 22, 2026

README check ran. 1 issue found and applied: added missing logs command to the command table. README.md has been updated in this branch.

@github-project-automation github-project-automation bot moved this from In progress to In review in CLI Development Feb 22, 2026
@kfirstri kfirstri merged commit 6309887 into main Feb 22, 2026
10 checks passed
@kfirstri kfirstri deleted the function-logs-command branch February 22, 2026 15:24
@github-project-automation github-project-automation bot moved this from In review to Done in CLI Development Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants