feat: add commands to manage Apex debug log trace flags @W-24222806@ - #970
Merged
Merged
Conversation
…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
…{verb} @W-24222806@
# Conflicts: # command-snapshot.json
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
approved these changes
Sep 28, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
sf apex trace list— lists all trace flags in the org with table displaysf apex trace create— creates a trace flag for a user/class/trigger with configurable debug level, log type, and durationsf apex trace delete— deletes a trace flag by IDWork Item
@W-24222806@: add command to manage Apex Debug log trace files
Proof of Work
Validation
Test plan
sf apex trace list --target-org <org>— verify table output with active trace flagssf apex trace list --target-org <org> --json— verify JSON output matches typesf apex trace create --traced-entity-id <userId> --debug-level SFDC_DevConsole --target-org <org>— verify trace flag createdsf apex trace createwith--duration 60 --log-type USER_DEBUG— verify custom optionssf apex trace create --debug-level NonExistent— verify error messagesf apex trace delete --trace-flag-id <id> --target-org <org>— verify deletionsf apex trace delete --trace-flag-id <invalidId>— verify error handling