Skip to content

feat: add commands to manage Apex debug log trace flags @W-24222806@ - #970

Merged
soridalac merged 16 commits into
mainfrom
wr/manageTraceFlags
Sep 28, 2026
Merged

soridalac merged 16 commits into
mainfrom
wr/manageTraceFlags

Conversation

@WillieRuemmele

@WillieRuemmele WillieRuemmele commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add sf apex trace list — lists all trace flags in the org with table display
  • Add sf apex trace create — creates a trace flag for a user/class/trigger with configurable debug level, log type, and duration
  • Add sf apex trace delete — deletes a trace flag by ID

Work Item

@W-24222806@: add command to manage Apex Debug log trace files

Proof of Work

  • Tests: 125 passing (9 new unit tests + NUT lifecycle test for trace flag commands)
  • Lint: 0 errors (6 pre-existing warnings)
  • Type check: clean
  • Build: clean
  • Adversarial review: 1 blocker resolved (SOQL injection), 3 warnings resolved (nullable types, invalid LogType, test coverage gaps)

Validation

  • Per-task review: cold adversarial reviewer identified SOQL injection risk, nullable type mismatch, invalid CLASS_TRACING LogType — all fixed
  • Integration: all checks pass (test, lint, build, snapshot, schema)

Test plan

  • sf apex trace list --target-org <org> — verify table output with active trace flags
  • sf apex trace list --target-org <org> --json — verify JSON output matches type
  • sf apex trace create --traced-entity-id <userId> --debug-level SFDC_DevConsole --target-org <org> — verify trace flag created
  • sf apex trace create with --duration 60 --log-type USER_DEBUG — verify custom options
  • sf apex trace create --debug-level NonExistent — verify error message
  • sf apex trace delete --trace-flag-id <id> --target-org <org> — verify deletion
  • sf apex trace delete --trace-flag-id <invalidId> — verify error handling

…04446@

Allow users to control the debug log verbosity when executing anonymous Apex.
--debug-level sets a predefined SOAP log type (NONE, DEBUGONLY, DB, PROFILING,
CALLOUT, DETAIL). --category-level sets individual category levels for
fine-grained control (e.g., Apex_code=FINEST, Db=FINE).
- Use indexOf('=') for robust key=value parsing (handles extra = segments)
- Trim whitespace from parsed category and level values
- Deduplicate category-level entries (last-wins when same category repeated)
- Add CLI examples for --debug-level and --category-level flags
- Add test for duplicate category deduplication
Add three new commands for managing TraceFlag objects:
- sf apex list trace — list all trace flags in the org
- sf apex create trace — create a trace flag for a user/class/trigger
- sf apex delete trace — delete a trace flag by ID
- Escape single quotes in debug-level SOQL query to prevent injection
- Make DebugLevel/TracedEntity nullable in TraceFlagRecord type
- Remove invalid CLASS_TRACING from log-type options
- Add explicit columns config to list table
- Add test for null relationship field fallbacks
- Add date duration assertion in create test
@WillieRuemmele
WillieRuemmele requested a review from a team as a code owner September 21, 2026 15:40
WillieRuemmele and others added 8 commits September 21, 2026 09:40
Show Active/Expired status in both table and JSON output so users can
quickly identify which trace flags are still capturing logs.
…ands (#973)

* fix: embellish/edit the --help for the 3 new "apex trace" commands

* Clarify trace flag deletion instructions in documentation

Updated documentation for deleting a trace flag to clarify usage in different orgs.

* Improve documentation for list trace flags command

Updated the description and examples for clarity and added a command for creating trace flags.
@soridalac

soridalac commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

QA notes:
✅: apex trace list — table output with trace flags, displays Active/Expired status per row
Screenshot 2026-09-28 at 12 56 34 PM

✅: apex trace list --json — JSON matches schema
✅: apex trace create — creates with defaults (DEVELOPER_LOG, 30min)
✅: apex trace create — custom log-type + duration
✅: apex trace create — nonexistent debug level errors cleanly
✅: apex trace delete — deletes by ID
✅: apex trace delete — nonexistent ID errors cleanly

@soridalac
soridalac merged commit b81b111 into main Sep 28, 2026
15 checks passed
@soridalac
soridalac deleted the wr/manageTraceFlags branch September 28, 2026 21:06
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.

3 participants