Skip to content

Conversation

@0xBigBoss
Copy link

Summary

Implements #6652 - adds filtering and JSON output capabilities to tilt logs:

  • --since: Filter logs by time (e.g., --since 5m, --since 1h)
  • --tail: Limit output to last N lines (applies only to initial history when combined with -f)
  • --json: Output logs as JSON Lines (JSONL) format
  • --json-fields: Configure JSON output fields (minimal, full, or comma-separated)

Usage Examples

# Time-based filtering
tilt logs --since 5m
tilt logs api --since 1h

# Tail limiting
tilt logs --tail 100
tilt logs --tail 50 -f  # Last 50 lines, then stream all new

# JSON output
tilt logs --json
tilt logs --json --json-fields=full
tilt logs --json --json-fields=time,resource,message

Implementation

  • Extends LogFilter with Since/Tail fields and time-based filtering
  • Adds JSONPrinter for structured JSONL output with configurable fields
  • Uses pointer types in JSONLogLine to distinguish "not included" from "empty value"
  • LogStreamer tracks isFirstBatch to apply tail only to initial history in follow mode

Follows existing patterns from --level and --source flags (PR #6513).

Test plan

  • Unit tests for time-based filtering (TestLogFilterApplyWithSince)
  • Unit tests for tail limiting (TestLogFilterApplyWithTail)
  • Unit tests for JSON output (TestJSONPrinter*)
  • Integration tests for LogStreamer
  • go vet passes
  • go build succeeds
  • Manual testing with tilt logs --help

Closes #6652

@0xBigBoss 0xBigBoss force-pushed the feat/logs-since-tail-json-clean branch from fcbc0e8 to 0d668ef Compare January 5, 2026 23:19
Implements tilt-dev#6652 - adds filtering and JSON output capabilities to tilt logs:

- --since: Filter logs by time (e.g., "5m", "1h", "30s")
- --tail: Limit output to last N lines (applies only to initial history
  when combined with -f/--follow)
- --json: Output logs as JSON Lines (JSONL) format
- --json-fields: Configure JSON output fields ("minimal", "full", or
  comma-separated field list)

Implementation details:
- Extends LogFilter with Since/Tail fields and time-based filtering
- Adds JSONPrinter for structured JSONL output with configurable fields
- Uses pointer types in JSONLogLine to distinguish "not included" from
  "empty value" for --json-fields=full
- LogStreamer tracks isFirstBatch to apply tail only to initial history
- Validates --since (positive duration), --tail (>= -1), and --json-fields
  (rejects unknown field names)

Closes tilt-dev#6652

Signed-off-by: Big Boss <[email protected]>
@0xBigBoss 0xBigBoss force-pushed the feat/logs-since-tail-json-clean branch from 0d668ef to acd5e01 Compare January 5, 2026 23:56
@0xBigBoss 0xBigBoss marked this pull request as ready for review January 6, 2026 13:30
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.

feat(cli): enhance tilt logs with --since, --tail, and --json flags

1 participant