Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.mobile.android-logcat/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Tools->Open Terminal is now supported on Linux Editor.
- Fixed Tools->Open Terminal not opening a window on Windows Editor when running on CoreCLR.
- Added a Commands window, accessible via the Tools menu in the Android Logcat window. It lets you save, organize, search and run adb commands which don't have a dedicated UI in this package, such as package management, permissions, dumpsys, settings and Meta Quest properties. Commands run asynchronously so the Editor stays responsive, support `<placeholder>` substitution with per-token examples and suggestions, and can be imported and exported as JSON. Catalog commands display a description of what they do when you hover over them. Edit Mode supports selecting several commands and deleting them in one step.
- 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.

## [1.4.7] - 2025-12-12
### Fixes & Improvements
Expand Down
4 changes: 2 additions & 2 deletions com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,10 @@ internal string LogPrintFormat

internal static readonly Regex m_CrashMessageRegex = new Regex(@"^\s*#\d{2}\s*pc\s([a-fA-F0-9]{8}).*(libunity\.so|libmain\.so)", RegexOptions.Compiled);
// Regex for messages produced via 'adb logcat -s -v year *:V'
internal static readonly Regex m_LogCatEntryYearRegex = new Regex(@"(?<date>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?<pid>\d+)\s+(?<tid>\d+)\s+(?<priority>[VDIWEFS])\s+(?<tag>.+?)\s*:\s(?<msg>.*)", RegexOptions.Compiled);
internal static readonly Regex m_LogCatEntryYearRegex = new Regex(@"(?<date>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?<pid>\d+)\s+(?<tid>\d+)\s+(?<priority>[VDIWEFS])\s+(?<tag>.+?)\s*:(?:\s(?<msg>.*)|$)", RegexOptions.Compiled);

// Regex for messages produced via 'adb logcat -s -v threadtime *:V'
internal static readonly Regex m_LogCatEntryThreadTimeRegex = new Regex(@"(?<date>\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?<pid>\d+)\s+(?<tid>\d+)\s+(?<priority>[VDIWEFS])\s+(?<tag>.+?)\s*:\s(?<msg>.*)", RegexOptions.Compiled);
internal static readonly Regex m_LogCatEntryThreadTimeRegex = new Regex(@"(?<date>\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?<pid>\d+)\s+(?<tid>\d+)\s+(?<priority>[VDIWEFS])\s+(?<tag>.+?)\s*:(?:\s(?<msg>.*)|$)", RegexOptions.Compiled);


internal static readonly int kUnityHashCode = "Unity".GetHashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,65 @@ public void WhitespacesArePreservedInMessage()
Assert.IsTrue(threadMsg.Equals(myTestMessage));
}

[Test]
public void EmptyMessagesAreParsedCorrectly()
{
// Message ending with colon (no trailing space)
var msgYearNoSpace = @"2018-10-25 14:27:29.803 1277 10543 E ctxmgr :";
var matchYearNoSpace = AndroidLogcat.m_LogCatEntryYearRegex.Match(msgYearNoSpace);
Assert.IsTrue(matchYearNoSpace.Success);
Assert.AreEqual("ctxmgr", matchYearNoSpace.Groups["tag"].Value);
Assert.AreEqual(string.Empty, matchYearNoSpace.Groups["msg"].Value);

var msgThreadNoSpace = "10-25 14:27:29.803 1277 10543 E ctxmgr :";
var matchThreadNoSpace = AndroidLogcat.m_LogCatEntryThreadTimeRegex.Match(msgThreadNoSpace);
Assert.IsTrue(matchThreadNoSpace.Success);
Assert.AreEqual("ctxmgr", matchThreadNoSpace.Groups["tag"].Value);
Assert.AreEqual(string.Empty, matchThreadNoSpace.Groups["msg"].Value);

// Message ending with colon and single space (empty message body)
var msgYearWithSpace = @"2018-10-25 14:27:29.803 1277 10543 E ctxmgr : ";
var matchYearWithSpace = AndroidLogcat.m_LogCatEntryYearRegex.Match(msgYearWithSpace);
Assert.IsTrue(matchYearWithSpace.Success);
Assert.AreEqual("ctxmgr", matchYearWithSpace.Groups["tag"].Value);
Assert.AreEqual(string.Empty, matchYearWithSpace.Groups["msg"].Value);

var msgThreadWithSpace = "10-25 14:27:29.803 1277 10543 E ctxmgr : ";
var matchThreadWithSpace = AndroidLogcat.m_LogCatEntryThreadTimeRegex.Match(msgThreadWithSpace);
Assert.IsTrue(matchThreadWithSpace.Success);
Assert.AreEqual("ctxmgr", matchThreadWithSpace.Groups["tag"].Value);
Assert.AreEqual(string.Empty, matchThreadWithSpace.Groups["msg"].Value);

// Tag containing a colon with empty message
var msgYearTagWithColonNoSpace = @"2018-10-25 14:27:29.803 1277 10543 E BarTender:BatteryStatsDumper:";
var matchYearTagWithColonNoSpace = AndroidLogcat.m_LogCatEntryYearRegex.Match(msgYearTagWithColonNoSpace);
Assert.IsTrue(matchYearTagWithColonNoSpace.Success);
Assert.AreEqual("BarTender:BatteryStatsDumper", matchYearTagWithColonNoSpace.Groups["tag"].Value);
Assert.AreEqual(string.Empty, matchYearTagWithColonNoSpace.Groups["msg"].Value);

var msgThreadTagWithColonNoSpace = "10-25 14:27:29.803 1277 10543 E BarTender:BatteryStatsDumper:";
var matchThreadTagWithColonNoSpace = AndroidLogcat.m_LogCatEntryThreadTimeRegex.Match(msgThreadTagWithColonNoSpace);
Assert.IsTrue(matchThreadTagWithColonNoSpace.Success);
Assert.AreEqual("BarTender:BatteryStatsDumper", matchThreadTagWithColonNoSpace.Groups["tag"].Value);
Assert.AreEqual(string.Empty, matchThreadTagWithColonNoSpace.Groups["msg"].Value);
}

[Test]
public void TabAfterColonIsParsedAsMessageDelimiter()
{
var msgYearWithTab = "2018-10-25 14:27:29.803 1277 10543 E mytag:\thello";
var matchYearWithTab = AndroidLogcat.m_LogCatEntryYearRegex.Match(msgYearWithTab);
Assert.IsTrue(matchYearWithTab.Success);
Assert.AreEqual("mytag", matchYearWithTab.Groups["tag"].Value);
Assert.AreEqual("hello", matchYearWithTab.Groups["msg"].Value);

var msgThreadWithTab = "10-25 14:27:29.803 1277 10543 E mytag:\thello";
var matchThreadWithTab = AndroidLogcat.m_LogCatEntryThreadTimeRegex.Match(msgThreadWithTab);
Assert.IsTrue(matchThreadWithTab.Success);
Assert.AreEqual("mytag", matchThreadWithTab.Groups["tag"].Value);
Assert.AreEqual("hello", matchThreadWithTab.Groups["msg"].Value);
}

[Test]
public void CorrectlyParsePidsWithWindowsEndlines()
{
Expand Down