public void AddLogEntry(string InMessage, bool bIsError = false)
        {
            if (InMessage != null)
            {
                LogEntry logEntry = new LogEntry();
                logEntry.Message  = InMessage;
                logEntry.DateTime = DateTime.Now;

                LogViewer.EMessageType InMessageType = bIsError ? LogViewer.EMessageType.Error : LogViewer.EMessageType.Info;

                if (bIsError == false)
                {
                    const string StepPattern           = @"\*{6} \[(\d+)\/(\d+)\]";
                    const string WarningPattern        = @"warning|\*\*\* Unable to determine ";
                    const string DebugPattern          = @".+\*\s\D\d\D\d\D\s\w+|.+\*\sFor\sUE4";
                    const string ErrorPattern          = @"Error_Unknown|ERROR|exited with code 1";
                    const string ProcessedFilesPattern = @"\w.+\.(cpp|cc|c|h|ispc)";

                    Regex StepRgx           = new Regex(StepPattern, RegexOptions.IgnoreCase);
                    Regex WarningRgx        = new Regex(WarningPattern, RegexOptions.IgnoreCase);
                    Regex DebugRgx          = new Regex(DebugPattern, RegexOptions.IgnoreCase);
                    Regex ErrorRgx          = new Regex(ErrorPattern, RegexOptions.IgnoreCase);
                    Regex ProcessedFilesRgx = new Regex(ProcessedFilesPattern, RegexOptions.IgnoreCase);

                    if (StepRgx.IsMatch(InMessage))
                    {
                        GroupCollection captures = StepRgx.Match(InMessage).Groups;
                        ChangeStepLabel(captures[1].Value, captures[2].Value);
                        CompiledFiles = 0;
                    }

                    if (ProcessedFilesRgx.IsMatch(InMessage))
                    {
                        CompiledFiles++;
                        CompiledFilesTotal++;
                        Dispatcher.Invoke(() => { ProcessedFilesLabel.Content = $"[Compiled: {CompiledFiles}. Total: {CompiledFilesTotal}]"; });
                    }

                    if (WarningRgx.IsMatch(InMessage))
                    {
                        NumWarnings++;
                        InMessageType = LogViewer.EMessageType.Warning;
                    }
                    else if (ErrorRgx.IsMatch(InMessage))
                    {
                        NumErrors++;
                        InMessageType = LogViewer.EMessageType.Error;
                    }
                    else if (DebugRgx.IsMatch(InMessage))
                    {
                        InMessageType = LogViewer.EMessageType.Debug;
                    }
                }

                LogControl.AddLogEntry(logEntry, InMessageType);
                LogMessage += InMessage + "\r\n";
            }
        }
예제 #2
0
        private void AddLogEntry(string InMessage, bool bIsError = false)
        {
            if (InMessage != null)
            {
                LogEntry logEntry = new LogEntry();
                logEntry.Message  = InMessage;
                logEntry.DateTime = DateTime.Now;

                LogViewer.EMessageType InMessageType = bIsError ? LogViewer.EMessageType.Error : LogViewer.EMessageType.Info;

                if (bIsError == false)
                {
                    const string StepPattern    = @"\*{6} \[(\d*)\/(\d*)\]";
                    const string WarningPattern = @"warning|\*\*\* Unable to determine ";
                    const string DebugPattern   = @".+\*\s\D\d\D\d\D\s\w+|.+\*\sFor\sUE4";
                    const string ErrorPattern   = @"Error_Unknown|ERROR|exited with code 1";

                    Regex StepRgx    = new Regex(StepPattern, RegexOptions.IgnoreCase);
                    Regex WarningRgx = new Regex(WarningPattern, RegexOptions.IgnoreCase);
                    Regex DebugRgx   = new Regex(DebugPattern, RegexOptions.IgnoreCase);
                    Regex ErrorRgx   = new Regex(ErrorPattern, RegexOptions.IgnoreCase);
                    if (StepRgx.IsMatch(InMessage))
                    {
                        var captures = StepRgx.Match(InMessage).Captures;
                        ChangeStepLabel(captures[0].Value, captures[1].Value);
                    }
                    if (WarningRgx.IsMatch(InMessage))
                    {
                        NumWarnings++;
                        InMessageType = LogViewer.EMessageType.Warning;
                    }
                    else if (ErrorRgx.IsMatch(InMessage))
                    {
                        NumErrors++;
                        InMessageType = LogViewer.EMessageType.Error;
                    }
                    else if (DebugRgx.IsMatch(InMessage))
                    {
                        InMessageType = LogViewer.EMessageType.Debug;
                    }
                }

                LogControl.AddLogEntry(logEntry, InMessageType);
                LogMessage += InMessage + "\r\n";
            }
        }