Add base44 logs command for fetching function runtime logs#225
Add base44 logs command for fetching function runtime logs#225
base44 logs command for fetching function runtime logs#225Conversation
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.0.33-pr.225.3509af6Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.0.33-pr.225.3509af6"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.0.33-pr.225.3509af6"
}
}
Preview published to npm registry — try new features instantly! |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
|
Found 2 issues:
See full details in review comment. |
Code Review - Detailed FindingsIssue 1: FunctionNotFoundError location violates CLAUDE.mdFile: src/core/resources/function/api.ts (lines 11-38) Problem: The PR defines References:
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 normalizeDatetimeFile: 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: Fixed: 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>
|
README check ran. 1 issue found and applied: added missing |
cbeef0e to
deb9871
Compare
|
README check ran. 1 issue found and applied: added missing |
Note
Description
This PR adds a
base44 logscommand 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 PythonKeyErrorbackend responses to HTTP 404 so the CLI can surface helpful "function not found" error messages.Related Issue
None
Type of Change
Changes Made
src/cli/commands/project/logs.ts— Newlogscommand implementation with support for--function,--since,--until,--limit,--order, and--jsonflags; fetches logs for all project functions when no--functionis specified, and merges/sorts results when multiple functions are queriedsrc/core/resources/function/api.ts— NewfetchFunctionLogs()API function that callsGET functions-mgmt/{name}/logswith query-string filters, validated via Zodsrc/core/resources/function/schema.ts— New Zod schemas and TypeScript types forFunctionLogEntry,FunctionLogsResponse, andFunctionLogFilterssrc/core/errors.ts—ApiError.fromHttpError()now normalizes backendKeyErrorresponses to 404 status to enable accurate "not found" error handlingsrc/cli/utils/runCommand.ts— Addedstdoutfield toRunCommandResultso commands can write pipeable/machine-readable output after the clack UI finishes; also removed the extra leading blank line fromrunCommandsrc/cli/program.ts— Registers the newlogscommandtests/cli/logs.spec.ts— Full integration test suite covering single/multi-function fetch, all-functions fallback, empty results,--jsonoutput, invalid options, and API error handlingtests/cli/testkit/Base44APIMock.ts— AddedmockFunctionLogs()andmockFunctionLogsError()helpers to the API mockREADME.md— Addedlogsentry to the commands tableTesting
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional 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
--limitoption is applied after merging so the total result count respects the cap across all functions. Thestdoutfield added toRunCommandResultis a general-purpose mechanism that any future command needing pipeable output can reuse.🤖 Generated by Claude | 2026-02-22 00:00 UTC