Skip to content

fix: allow logcat regex parser to parse empty log messages - #237

Merged
todi1856 merged 3 commits into
Unity-Technologies:masterfrom
reginaldalfret:fix/logcat-empty-msg-regex
Nov 17, 2026
Merged

todi1856 merged 3 commits into
Unity-Technologies:masterfrom
reginaldalfret:fix/logcat-empty-msg-regex

Conversation

@reginaldalfret

@reginaldalfret reginaldalfret commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of this PR

Fixed logcat regex parsers (m_LogCatEntryYearRegex and m_LogCatEntryThreadTimeRegex) failing to match log lines with an empty message body (e.g. tag: or tag: ).

Previously, the regex ended with :\s(?<msg>.*), which required at least one whitespace character after the colon. When an Android logcat line had an empty message body without trailing spaces, the regex match failed, causing the line to be treated as an unparsable error entry (LogEntryParserErrorFor).

This PR:

  • Updates the regex suffix to :(?:\s(?<msg>.*)|$), matching empty message bodies ending at the colon or with trailing whitespace, preserving any leading whitespace when message content is present, while correctly matching tags containing colons (e.g. BarTender:BatteryStatsDumper:).
  • Adds unit test cases in AndroidLogcatRegexTests.cs verifying empty messages in both year and threadtime formats, tags with colons, and whitespace delimiters.
  • Updates CHANGELOG.md.

Comments to Reviewers

All regex unit tests pass cleanly.

- Support log entries where message body is empty or has no trailing space after the tag colon
- Preserve leading whitespace when message content is present
- Add unit tests covering year and threadtime format with empty message bodies
- Update CHANGELOG.md

@todi1856 todi1856 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.

Sorry, but this code introduces some regressions

LogMessageRegexMatchesForThreadTimeFormat (0.002s)
---
  Expected string length 28 but was 9. Strings differ at index 9.
  Expected: "BarTender:BatteryStatsDumper"
  But was:  "BarTender"

LogMessageRegexMatchesForYearFormat (0.000s)
---
  Expected string length 28 but was 9. Strings differ at index 9.
  Expected: "BarTender:BatteryStatsDumper"
  But was:  "BarTender"
image

``
A second, smaller regression: a tab after the colon (tag:\thello) used to parse to msg=hello. Now it parses with an empty message, because \s was swapped for a literal space.

…cat regex

- Use ':(?:\s(?<msg>.*)|$)' so colons in tags (e.g. BarTender:BatteryStatsDumper) continue matching correctly
- Preserve \s whitespace delimiter support including tabs (\t) after the colon
- Support empty log messages ending with colon or colon with trailing whitespace
- Add unit tests for colons in tags with empty message and tab message delimiters
@reginaldalfret

Copy link
Copy Markdown
Contributor Author

Hi @todi1856,

Thank you for catching those regressions!

Root Cause

  1. Tags containing colons (e.g. \BarTender:BatteryStatsDumper): With the previous optional group :(?: (?.*))?, the lazy quantifier .+?\ matched at the first colon inside the tag (\BarTender:), stopping early because the following space-prefixed group was optional.
  2. Tab delimiters (\ ag:\thello): Swapping \s\ for a literal space caused tabs to fail matching the message group.

Resolution

Updated the regex suffix to:
\
egex
:(?:\s(?.*)|$)
\\

  • Tags containing colons: At internal colons (\BarTender:), the character following the colon is neither whitespace (\s) nor end of line ($), so the lazy quantifier correctly continues matching to the true delimiter colon.
  • Whitespace delimiters (\s): Restores matching all whitespace delimiters (including \t).
  • Empty messages: Matches empty message bodies ending at the colon ($) or with trailing whitespace.

Added unit test coverage in \AndroidLogcatRegexTests.cs\ for:

  • Tags containing colons with empty message bodies (\BarTender:BatteryStatsDumper:)
  • Tab delimiters after colons (\mytag:\thello)
  • Empty messages with and without trailing spaces
  • Messages with preserved leading whitespace

The commit has been pushed to this PR branch.

@todi1856 todi1856 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.

Also pls merge master to resolve conflict

- Recordings can be played in the Screen Capture window, with play/pause, a time slider and buttons that step one frame back or forward.
- Tools->Open Terminal is now supported on Linux Editor.
- Fixed Tools->Open Terminal not opening a window on Windows Editor when running on CoreCLR.
- Fixed logcat regex parser failing on empty log messages or messages without a space after the tag colon.

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.

I think this should say

Fixed log lines with an empty message not being parsed. They appeared as unformatted text with no tag, process ID or priority, and were hidden when filtering by tag.

since this PR doesn't fix "messages without a space after the tag colon." and if I I understand correctly, it can't be fixed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the CHANGELOG entry to the requested description and merged master to resolve the conflict.

@reginaldalfret

Copy link
Copy Markdown
Contributor Author

Hi @todi1856,

Merged origin/master into this branch to resolve the conflict and updated the CHANGELOG.md entry as requested:

- Fixed log lines with an empty message not being parsed. They appeared as unformatted text with no tag, process ID or priority, and were hidden when filtering by tag.

All commits have been pushed and the PR is ready for re-review!

@todi1856 todi1856 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.

Thank you for the fix ! Much appreciated

@todi1856
todi1856 merged commit c1fa6c3 into Unity-Technologies:master Nov 17, 2026
3 checks passed
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.

2 participants