diff --git a/com.unity.mobile.android-logcat/CHANGELOG.md b/com.unity.mobile.android-logcat/CHANGELOG.md index 0b8e4a06..8150b597 100644 --- a/com.unity.mobile.android-logcat/CHANGELOG.md +++ b/com.unity.mobile.android-logcat/CHANGELOG.md @@ -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 `` 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 diff --git a/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs b/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs index 25cfb9fe..4912c500 100644 --- a/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs +++ b/com.unity.mobile.android-logcat/Editor/AndroidLogcat.cs @@ -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(@"(?\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?\d+)\s+(?\d+)\s+(?[VDIWEFS])\s+(?.+?)\s*:\s(?.*)", RegexOptions.Compiled); + internal static readonly Regex m_LogCatEntryYearRegex = new Regex(@"(?\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?\d+)\s+(?\d+)\s+(?[VDIWEFS])\s+(?.+?)\s*:(?:\s(?.*)|$)", RegexOptions.Compiled); // Regex for messages produced via 'adb logcat -s -v threadtime *:V' - internal static readonly Regex m_LogCatEntryThreadTimeRegex = new Regex(@"(?\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?\d+)\s+(?\d+)\s+(?[VDIWEFS])\s+(?.+?)\s*:\s(?.*)", RegexOptions.Compiled); + internal static readonly Regex m_LogCatEntryThreadTimeRegex = new Regex(@"(?\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(?\d+)\s+(?\d+)\s+(?[VDIWEFS])\s+(?.+?)\s*:(?:\s(?.*)|$)", RegexOptions.Compiled); internal static readonly int kUnityHashCode = "Unity".GetHashCode(); diff --git a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRegexTests.cs b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRegexTests.cs index 40807f79..f01867b4 100644 --- a/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRegexTests.cs +++ b/com.unity.mobile.android-logcat/Tests/Editor/AndroidLogcatRegexTests.cs @@ -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() {