Skip to content

feat(logs): add --env flag to fetch preview, prod, or all logs#551

Open
ImriKochWix wants to merge 3 commits into
mainfrom
feat/logs-env-param
Open

feat(logs): add --env flag to fetch preview, prod, or all logs#551
ImriKochWix wants to merge 3 commits into
mainfrom
feat/logs-env-param

Conversation

@ImriKochWix

@ImriKochWix ImriKochWix commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Note

Description

Enhances the base44 logs command with environment targeting, a JSON output format, and ergonomic relative-time shortcuts. Logs now default to the preview environment, support --env preview|prod selection (with a helpful empty-state hint for unpublished production apps), and can emit machine-readable JSON via --format json for scripting and piping. The per-function fetch logic is also refactored into a dedicated helper for clarity.

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

  • Added --env <preview|prod> option to fetch logs from a specific environment, defaulting to preview; the env filter is plumbed through FunctionLogFilters and the logs query string.
  • Added --format <text|json> option (default text); --format json prints pretty-printed JSON, suppresses the outro message, and runs the command in quiet/raw output mode via Base44Command.isRawOutputMode().
  • Added relative-time shortcuts for --since/--until (e.g. 1h, 30m, 7d), resolved to ISO timestamps in normalizeDatetime().
  • Added a tailored empty-state hint when no production logs are found, suggesting the app may be unpublished and pointing to --env preview.
  • Extracted per-function log fetching (including the 404 "function not found" handling) into a fetchLogsForFunction() helper.
  • Added tests covering JSON output, invalid --format rejection, and relative --since shortcuts.

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

The --env all option from an earlier iteration was dropped; logs now default to preview. JSON output is designed to be pipe-friendly (banner and outro suppressed) for downstream tooling.


🤖 Generated by Claude | 2026-06-24 07:53 UTC | 6632e1b

Default is "all": fetches both preview and prod per function,
merges by time, and deduplicates entries that appear in both
(when draft == published, same deployment ID returns same logs).

Backend changes required: send env=preview|prod query param.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.56-pr.551.6632e1b

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.56-pr.551.6632e1b"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.56-pr.551.6632e1b"
  }
}

Preview published to npm registry — try new features instantly!

ImriKochWix and others added 2 commits June 22, 2026 23:14
…hint

- Remove "all" env option; preview/prod only
- Default to preview (consistent with industry standard of "current context")
- When --env prod returns empty, show: "No production logs found. Has this
  app been published? Try --env preview to see draft logs."
- Simplify fetchLogsForFunctions (no more merge/dedup needed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- --format json outputs clean JSON (no UI chrome) for piping to jq etc.
- --since/--until now accept relative shorthands: 1h, 30m, 2d
- Suppress clack intro/outro when --format json via isRawOutputMode()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant