Skip to content

Preserve bracket fields and message when SquareBracketColumnizer applies a time offset - #754

Open
EnesKartal wants to merge 2 commits into
LogExperts:Developmentfrom
EnesKartal:fix/issue-713
Open

EnesKartal wants to merge 2 commits into
LogExperts:Developmentfrom
EnesKartal:fix/issue-713

Conversation

@EnesKartal

Copy link
Copy Markdown

Fixes #713

Root Cause

In SquareBracketColumnizer.SplitLine, when _timeOffset != 0, only the reformatted timestamp string (newDate) was passed to SquareSplit, discarding the remainder of the log line starting at endPos. As a result, all bracketed fields and the message column were returned empty.

Fix

  • Concatenate newDate with temp.Span[endPos..] before passing the shifted line to SquareSplit (using newDate.Length as the timestamp end position).
  • Leave the underlying ILogLineMemory.FullLine unmodified.

Tests

  • Added SplitLine_TimeOffset_PreservesBracketFieldsAndMessage covering zero, positive (+123 ms), negative (-506 ms), and reset-to-zero offsets.
  • Added SplitLine_TimeOffsetCrossesMidnight_ShiftsDateAndPreservesRemainingColumns covering forward and backward date rollovers.
  • Ran SquareBracketColumnizerTest and MarkerColumnizerSnapshotTests (12 passed, 0 failed) and the full LogExpert.Tests suite (1032 passed, 7 skipped, 0 failed).

@Hirogen Hirogen closed this Nov 20, 2026
@Hirogen Hirogen reopened this Nov 20, 2026

@Hirogen Hirogen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! The fix looks right. Using newDate.Length for the timestamp end position is actually more robust than endPos, and the tests cover exactly what #713 asked for (zero, positive and negative offsets, midnight rollover both ways, reset to 0, and the log line itself left unchanged).

Two small requests before I merge:

  1. Nested-bracket case under an offset. Could you add one test that applies a nonzero offset to a line with a nested field, e.g. 2022-03-21 11:34:34.505[INFO][ProgramName/MethodName[41]]Message, and checks that [ProgramName/MethodName[41]] stays one column? That's the #460 behavior, and it's the one column shape the new tests don't cover yet.
  2. Issue reference comment. Please put a one-line // Issue #713: ... comment above the new tests, like the existing #460 test has.

Optional: the Select(c => c.FullValue.ToString()) assertion appears six times, so a small helper would tidy it up. Inline is fine too.

Thanks again!

@EnesKartal

Copy link
Copy Markdown
Author

Thanks for the review! Addressed in d541416:

  • Added \SplitLine_TimeOffsetWithNestedBrackets_KeepsInnerBracketsInOneColumn\ covering \2022-03-21 11:34:34.505[INFO][ProgramName/MethodName[41]]Message\ with a nonzero offset.
  • Added // Issue Square Bracket timeshift drops bracket fields and message #713: ...\ comments above each of the new tests.
  • Extracted a small \GetColumnTexts\ helper for the column value assertions.

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.

Square Bracket timeshift drops bracket fields and message

2 participants