private void LogParsedMessage(LogMessage message) { var text = message.ToString(); string line = null; var textReader = new StringReader(text); while ((line = textReader.ReadLine()) != null) { var match = parseMessage.Match(line); if (match.Success) { var filePath = match.Groups[1].Value; var lineNumber = int.Parse(match.Groups[2].Value); var colNumberText = match.Groups[3].Value; int colStartNumber; int colEndNumber; var colMatch = matchNumberRange.Match(colNumberText); if (colMatch.Success) { int.TryParse(colMatch.Groups[1].Value, out colStartNumber); int.TryParse(colMatch.Groups[2].Value, out colEndNumber); } else { int.TryParse(colNumberText, out colStartNumber); colEndNumber = colStartNumber; } var msgType = match.Groups[4].Value; var msgCode = match.Groups[5].Value; var msgText = match.Groups[6].Value; if (string.Compare(msgType, "error", StringComparison.InvariantCultureIgnoreCase) == 0) { Log.LogError(string.Empty, msgCode, string.Empty, filePath, lineNumber, colStartNumber, lineNumber, colEndNumber, msgText); } else if (string.Compare(msgType, "warning", StringComparison.InvariantCultureIgnoreCase) == 0) { Log.LogWarning(string.Empty, msgCode, string.Empty, filePath, lineNumber, colStartNumber, lineNumber, colEndNumber, msgText); } else if (string.Compare(msgType, "info", StringComparison.InvariantCultureIgnoreCase) == 0) { Log.LogWarning(string.Empty, msgCode, string.Empty, filePath, lineNumber, colStartNumber, lineNumber, colEndNumber, msgText); } else { Log.LogWarning(line); } } else { Log.LogWarning(line); } } }
/// <summary> /// Logs the message. /// </summary> /// <param name="message">The message.</param> public virtual void LogMessage(LogMessage message) { if (message.Type == LogMessageType.Error) HasErrors = true; Messages.Add(message); var handler = NewMessageLogged; if (handler != null) handler(this, message); }
private void LogSimpleMessage(LogMessage message) { switch (message.Type) { case LogMessageType.Warning: Log.LogWarning(message.Text); break; case LogMessageType.Error: Log.LogError(message.Text); break; case LogMessageType.Info: Log.LogMessage(MessageImportance.Low, message.Text); break; } }