public static void ProcessLog(LogType type, string message, string exceptionStack = null, params object[] args) { switch (type) { case LogType.Log: MessagesCount++; break; case LogType.Warning: WarningsCount++; break; case LogType.Error: case LogType.Assert: case LogType.Exception: ErrorsCount++; break; } var timing = (Timing)null; if (Timing.Running) { timing = new Timing("Processing Logs"); } try { current.LogString = string.Format(message, args); current.Type = type; if (string.IsNullOrEmpty(exceptionStack)) { var stack = new StackFrame(2, true); if (!string.IsNullOrEmpty(stack.GetFileName())) { current.FileName = stack.GetFileName(); current.LineNumber = stack.GetFileLineNumber(); current.StackTrace = string.Format(" at {0}, line {1}", Path.GetFileName(current.FileName), current.LineNumber); } } else { current.StackTrace = exceptionStack; } AllLogs.Add(current); writer.WriteLine(current); } catch (Exception e) { Debug.LogException(e); } if (timing != null) { timing.Dispose(); } }
public void AddLog(string message, string stacktrace, LogType type) { lock (_lock) { m_NeedToProcessLogs = true; var log = new LogEvent { LogType = type, Message = message, StackTrace = stacktrace, }; AllLogs.Add(log); if (IsNUnitResultStateException(stacktrace, type)) { if (message.StartsWith("SuccessException")) { IsNUnitException = true; IsNUnitSuccessException = true; if (message.StartsWith("SuccessException: ")) { NUnitExceptionMessage = message.Substring("SuccessException: ".Length); return; } } else if (message.StartsWith("InconclusiveException")) { IsNUnitException = true; IsNUnitInconclusiveException = true; if (message.StartsWith("InconclusiveException: ")) { NUnitExceptionMessage = message.Substring("InconclusiveException: ".Length); return; } } else if (message.StartsWith("IgnoreException")) { IsNUnitException = true; IsNUnitIgnoreException = true; if (message.StartsWith("IgnoreException: ")) { NUnitExceptionMessage = message.Substring("IgnoreException: ".Length); return; } } } if (IsFailingLog(type) && !IgnoreFailingMessages) { FailingLogs.Add(log); } } }
/// <summary> /// Handle gotten logs from server /// </summary> /// <param name="sender">server</param> /// <param name="message">logs list</param> public void HandleLogMessage(object sender, TCPEventArgs message) { try { List <JObject> temp = JsonConvert.DeserializeObject <List <JObject> >(message.Args); AllLogs.Clear(); foreach (JObject log in temp) { string logType = (string)log["logType"]; string logInfo = (string)log["logInfo"]; LogArgs toInsert = new LogArgs(logType, logInfo); AllLogs.Add(toInsert); } } catch (Exception) { } }
public bool AddLog(Log log) { AllLogs.Add(log); var text = GetLogAsString(log); try { File.AppendAllText(LogsFilepath, text + "\n"); } catch (Exception e) { return(true); } if (WriteIntoDebugOutput) { Debug.WriteLine(text); } if (WriteIntoConsoleOutput) { Console.WriteLine(text); } return(false); }