feat(log-viewer): read the user and entry point from the parser - #1077
Open
lukecotter wants to merge 1 commit into
Open
lukecotter wants to merge 1 commit into
lukecotter wants to merge 1 commit into
Conversation
The parser now hoists USER_INFO onto ApexLog, so the raw-text scan and the firstCodeUnit walk go. findEntryPoint is the same traversal statement for statement, so the header names the same code unit. deriveLogIdentity takes the log alone. The timezone is rebuilt from the parts the parser splits it into: the offset reproduces exactly, but a log stating a bare label gains a prefix it never carried. apex-log-parser#85 asks for the source text, which would replace the rebuild. The user is keyed on the name, not on the header line. The parser reports a USER_INFO with no name where the old scan reported nothing, and an empty name would render a separator around an empty item.
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.
📝 PR Overview
Stacked on #1068 — base is
feat-adopt-apex-log-parser, notmain.logIdentity.tscarriedTODO(spike): hoist USER_INFO onto ApexLog in the parser and drop the raw-text scan.0.1.1does exactly that, so the scan and the local code-unit walk both go. Theparser was already paying for its own
USER_INFOscan on every log, so this deletes duplicatedwork rather than moving it.
🛠️ Changes made
parseUserInfo(rawLog)andTIMESTAMPED_LINE→log.userInfo.deriveLogIdentitytakes thelog alone; the
rawLogparameter and the two now-false comment lines at the call site go.firstCodeUnit(log)→log.entryPoint. The parser'sfindEntryPointis the same traversalstatement for statement — same root-children order, same one-level descent into
ExecutionStartedLine, samenull— so the header names the same code unit.entryPointLabelstays local. It is display copy (Anonymous Apex,VF <page>,Trigger <name>), not parsing.nullfor aUSER_INFOwith no username; the parser returns{userName: ''}, which is truthy, so the headerwould have drawn a
•separator around an empty item with an empty tooltip. Covered by a new test.🧩 Type of change (check all applicable)
📷 Screenshots / gifs / video [optional]
None — the header renders as before. The start-time tooltip still reads
Started 10:29:24.600 (GMT-07:00) Pacific Daylight Time (America/Los_Angeles)onsample-app/debug-logs/sample-log.log, verified byte-for-byte against the old code.🔗 Related Issues
related apex-dev-tools/apex-log-parser#85
related apex-dev-tools/apex-log-parser#86
✅ Tests added?
Two added — the empty-username case above, and a header stating an offset but no zone name. One
deleted:
finds USER_INFO past a preamble longer than any fixed scan windowasserted parserbehaviour rather than ours. One renamed to what it actually asserts, since the parser searches
everything before
EXECUTION_STARTEDrather than bailing at the first timestamped line.2085 tests across 156 suites pass.
📚 Docs updated?
## [Unreleased]already carries "🪪 Header: shows the entry point, user and start time". Thisis the mechanism behind a shipped feature.
Anything else we need to know? [optional]
Verified:
pnpm lint0 errors · 2085 tests in 156 suites ·prettier --checkandtypecheckclean on the changed paths.
The timezone is re-synthesised, and that is not perfectly faithful. The parser splits the
USER_INFOtimezone field into{label, name, offsetMinutes}and keeps no copy of the original, sothe wording has to be rebuilt. The offset reproduces exactly, half-hour zones included, but four
distinct field spellings collapse into two parse results — nothing says whether the log carried a
(GMT…)prefix. Measured divergences:(GMT-07:00) Pacific Daylight Time (America/Los_Angeles)Greenwich Mean Time(GMT+01:00) Greenwich Mean Time— prefix added(GMTZ) Coordinated Universal Time (UTC)(GMT+00:00) …— respelledEach states something true; none states something false. The dominant shape — the only one in this
repo's real logs — is byte-identical. apex-log-parser#85 asks for the source text, which would
delete the rebuild entirely.
A parser bug ships with this, raised as apex-log-parser#86.
parseUserInfobounds its searchwith
log.indexOf('|EXECUTION_STARTED'), which can match inside theExecute Anonymous:sourceecho. Apex containing that literal loses the user chip and the tooltip's timezone. The same wrong
window means a log with no
EXECUTION_STARTEDcan take aUSER_INFOline out of aUSER_DEBUGpayload, and makes the scan cost 36 ms on a 50 MB log where it should cost microseconds. None is
fixable here without restoring the scan this PR removes.