public static void CaptureLogLineAround(int atLine, SourceFile source, LogLine ll)
        {
            string logType = source[atLine].Replace(LogKeyword, "");

            if (logType.StartsWith("Error"))
            {
                ll.logType = LogLine.LogType.Error;
            }
            else if (logType.StartsWith("Warning"))
            {
                ll.logType = LogLine.LogType.Warning;
            }
            else
            {
                ll.logType = LogLine.LogType.Log;
            }

            // Find head/tail, search up until we find double blank line
            int headLine = source.SearchForDoubleNewLine(atLine, SearchDirection.Up);
            int tailLine = source.SearchForDoubleNewLine(atLine, SearchDirection.Down);

            CaptureMethodCommon.FastForwardLineIfThereIsUnityInternalLogLine(ref headLine, tailLine, source);

            // 2019.4.26 log file uses another identifier
            int callStackStart = source.SearchForLineContaining(atLine, CallStackStart_2019_4_Early, SearchDirection.Up, limit: headLine);

            if (callStackStart < 0)
            {
                callStackStart = source.SearchForLineContaining(atLine, CallStackStart_2019_4_26, SearchDirection.Up, limit: headLine);
            }

            if (callStackStart < 0)
            {
                callStackStart = headLine + 1;// Default to one line message
                if (!s_CallStackStartFaultWarned)
                {
                    s_CallStackStartFaultWarned = true;
                    MessageBox.Show(
                        $"A pattern form 'callstack start' could not be found.\n" +
                        $"Like '{CallStackStart_2019_4_Early}' or '{CallStackStart_2019_4_26}'\n" +
                        $"Message and call stack might not fully extract in this run.\n" +
                        $"(Unity callstack function can change over versions, modify code to support more of them!)\n" +
                        $"This will only warn once.");
                }
            }

            // Usually message is just 1 line above Internal_Log
            ll.message   = source.CaptureTextFromToLine(headLine, callStackStart - 1);
            ll.callstack = source.CaptureTextFromToLine(callStackStart + 1, tailLine);

            ll.startFromSourceLine = headLine;
            ll.endAtSourceLine     = tailLine;
        }
Example #2
0
        public static void CaptureLogLineAround(int atLine, string[] allLines, LogLine ll)
        {
            // Type is always error for exception
            ll.type = LogLine.LogType.Error;

            // Find head/tail, search up until we find double blank line
            int head = SearchForDoubleNewLine(atLine, allLines, SearchDirection.Up);
            int tail = SearchForDoubleNewLine(atLine, allLines, SearchDirection.Down);

            CaptureMethodCommon.FastForwardLineIfThereIsUnityInternalLogLine(ref head, tail, allLines);

            // Callstack start is line with first "  at " keyword. which is this line from Detect
            int callStackStart = atLine;

            ll.message   = CaptureTextFromToLine(head, callStackStart - 1, allLines);
            ll.callstack = CaptureTextFromToLine(atLine, tail, allLines);

            ll.startFromSourceLine = head;
            ll.endAtSourceLine     = tail;
        }
Example #3
0
        public static void CaptureLogLineAround(int atLine, string[] allLines, LogLine ll)
        {
            string logType = allLines[atLine].Replace(LogKeyword, "");

            if (logType.StartsWith("Error"))
            {
                ll.type = LogLine.LogType.Error;
            }
            else if (logType.StartsWith("Warning"))
            {
                ll.type = LogLine.LogType.Warning;
            }
            else
            {
                ll.type = LogLine.LogType.Log;
            }

            // Find head/tail, search up until we find double blank line
            int head = SearchForDoubleNewLine(atLine, allLines, SearchDirection.Up);
            int tail = SearchForDoubleNewLine(atLine, allLines, SearchDirection.Down);

            CaptureMethodCommon.FastForwardLineIfThereIsUnityInternalLogLine(ref head, tail, allLines);

            int callStackStart = SearchForLineBeginWith(atLine, allLines, CallStackStart, SearchDirection.Up);

            if (head == callStackStart)
            {
                // The "message" ends with an extra \n. Look back for the actual message.
                head = SearchForDoubleNewLine(callStackStart - 2, allLines, SearchDirection.Up);
            }

            // Usually message is just 1 line above Internal_Log
            ll.message   = CaptureTextFromToLine(head, callStackStart - 1, allLines);
            ll.message   = ll.message.Replace('\n', ' ');
            ll.callstack = CaptureTextFromToLine(callStackStart + 1, tail, allLines);

            ll.startFromSourceLine = head;
            ll.endAtSourceLine     = tail;
        }