Пример #1
0
    void AddMessage(string category, StackFrameInfo stackFrame, string message)
    {
        var result = new StringBuilder();
        result.Append($"[{category}");

        if (!stackFrame.IsEmpty)
        {
            var fileName = stackFrame.FileName;
            if (fileName.StartsWith(currentDirectory))
                fileName = fileName.Substring(currentDirectory.Length + 1);

            result.Append($" @ {fileName}:{stackFrame.LineNumber}");
        }

        result.Append($"] => {message}");

        Messages.Add(result.ToString());
    }
Пример #2
0
    void AddMessage(string category, StackFrameInfo stackFrame, string message)
    {
        var result = new StringBuilder();
        result.AppendFormat("[{0}", category);

        if (!stackFrame.IsEmpty)
        {
            var fileName = stackFrame.FileName;
            if (fileName.StartsWith(currentDirectory))
                fileName = fileName.Substring(currentDirectory.Length + 1);

            result.AppendFormat(" @ {0}:{1}", fileName, stackFrame.LineNumber);
        }

        result.AppendFormat("] => {0}", message);

        Messages.Add(result.ToString());
    }
Пример #3
0
 public void LogImportantMessage(StackFrameInfo stackFrame, string message)
 {
     AddMessage("Imp", stackFrame, message);
 }
Пример #4
0
 public void LogMessage(StackFrameInfo stackFrame, string message)
 {
     AddMessage("---", stackFrame, message);
 }
        /// <summary>
        /// Lots test output to the logger.
        /// </summary>
        protected virtual void LogOutput(StackFrameInfo frameInfo, string output)
        {
            if (string.IsNullOrEmpty(output))
                return;

            // ITestOutputHelper terminates everything with NewLine, but we really don't need that
            // extra blank line in our output.
            if (output.EndsWith(Environment.NewLine, StringComparison.Ordinal))
                output = output.Substring(0, output.Length - Environment.NewLine.Length);

            Logger.LogMessage(frameInfo, "      Output:");

            foreach (var line in output.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
                Logger.LogImportantMessage(frameInfo, $"        {line}");
        }
Пример #6
0
 public void LogError(StackFrameInfo stackFrame, string message)
 {
     AddMessage("Err", stackFrame, message);
 }
 /// <inheritdoc/>
 public void LogWarning(StackFrameInfo stackFrame, string message)
 {
     using (SetColor(ConsoleColor.Yellow))
         lock (LockObject)
             Console.WriteLine(message);
 }
        /// <summary>
        /// Logs a stack trace to the logger.
        /// </summary>
        protected virtual void LogStackTrace(StackFrameInfo frameInfo, string stackTrace)
        {
            if (string.IsNullOrEmpty(stackTrace))
                return;

            Logger.LogMessage(frameInfo, "      Stack Trace:");

            foreach (var stackFrame in stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
                Logger.LogImportantMessage(frameInfo, $"        {StackFrameTransformer.TransformFrame(stackFrame, defaultDirectory)}");
        }
Пример #9
0
 /// <summary>
 /// Logs a high-priority formatted message with stack frame.
 /// </summary>
 /// <param name="logger">The logger</param>
 /// <param name="stackFrame">The stack frame information</param>
 /// <param name="messageFormat">The format of the message to be logged</param>
 /// <param name="args">The format arguments</param>
 public static void LogImportantMessage(this IRunnerLogger logger, StackFrameInfo stackFrame, string messageFormat, params object[] args)
 {
     logger.LogImportantMessage(stackFrame, string.Format(messageFormat, args));
 }
Пример #10
0
 /// <inheritdoc/>
 public void LogMessage(StackFrameInfo stackFrame, string message)
 {
     using (SetColor(ConsoleColor.DarkGray))
         lock (LockObject)
             Console.WriteLine(message);
 }
Пример #11
0
 public void LogWarning(StackFrameInfo stackFrame, string message)
 {
 }
Пример #12
0
 public void LogWarning(StackFrameInfo stackFrame, string message)
 {
     AddMessage("Wrn", stackFrame, message);
 }
Пример #13
0
 public void LogMessage(StackFrameInfo stackFrame, string message)
 {
 }
Пример #14
0
 public void LogImportantMessage(StackFrameInfo stackFrame, string message)
 {
 }
Пример #15
0
 public void LogError(StackFrameInfo stackFrame, string message)
 {
 }
Пример #16
0
 /// <inheritdoc/>
 public void LogImportantMessage(StackFrameInfo stackFrame, string message)
 {
     using (SetColor(ConsoleColor.Gray))
         lock (LockObject)
             Console.WriteLine(message);
 }
Пример #17
0
 /// <inheritdoc/>
 public void LogError(StackFrameInfo stackFrame, string message)
 {
     using (SetColor(ConsoleColor.Red))
         lock (LockObject)
             Console.Error.WriteLine(message);
 }
Пример #18
0
 /// <inheritdoc/>
 public void LogError(StackFrameInfo stackFrame, string message)
 {
     using (SetColor(ConsoleColor.Red))
         lock (LockObject)
             Console.Error.WriteLine(message);
 }
Пример #19
0
 /// <inheritdoc/>
 public void LogWarning(StackFrameInfo stackFrame, string message)
 {
     using (SetColor(ConsoleColor.Yellow))
         lock (LockObject)
             Console.WriteLine(message);
 }