Table of Contents

Class ConsoleRunnerLogger

Namespace
Xunit.Runner.Common
Assembly
xunit.v3.runner.common.dll

An implementation of IRunnerLogger which logs messages to a TextWriter (typically the one from Out).

public class ConsoleRunnerLogger : IRunnerLogger
Inheritance
ConsoleRunnerLogger
Implements
Inherited Members
Extension Methods

Constructors

ConsoleRunnerLogger(bool, bool, ConsoleHelper, bool)

Initializes a new instance of the ConsoleRunnerLogger class.

public ConsoleRunnerLogger(bool useColors, bool useAnsiColor, ConsoleHelper consoleHelper, bool waitForAcknowledgment)

Parameters

useColors bool

A flag to indicate whether colors should be used when logging messages.

useAnsiColor bool

A flag to indicate whether ANSI colors should be forced on Windows.

consoleHelper ConsoleHelper

The helper for writing console output.

waitForAcknowledgment bool

A flag to indicate whether the logger should wait for acknowledgments or not

Properties

LockObject

Gets a lock object that can be used to ensure that multiple calls to log messages will always be grouped together.

public object LockObject { get; }

Property Value

object

Methods

LogError(StackFrameInfo, string)

Logs an error message with stack frame.

public void LogError(StackFrameInfo stackFrame, string message)

Parameters

stackFrame StackFrameInfo

The stack frame information

message string

The message to be logged

LogImportantMessage(StackFrameInfo, string)

Logs a high-priority message with stack frame.

public void LogImportantMessage(StackFrameInfo stackFrame, string message)

Parameters

stackFrame StackFrameInfo

The stack frame information

message string

The message to be logged

LogMessage(StackFrameInfo, string)

Logs a normal-priority message with stack frame.

public void LogMessage(StackFrameInfo stackFrame, string message)

Parameters

stackFrame StackFrameInfo

The stack frame information

message string

The message to be logged

LogRaw(string)

Logs a messages with as little processing as possible. For example, the console runner will not attempt to set the color of the text that's being logged. This is most useful when attempting to render text lines that will be processed, like for TeamCity.

public void LogRaw(string message)

Parameters

message string

The message to be logged.

LogWarning(StackFrameInfo, string)

Logs a warning message with stack frame.

public void LogWarning(StackFrameInfo stackFrame, string message)

Parameters

stackFrame StackFrameInfo

The stack frame information

message string

The message to be logged

WaitForAcknowledgment()

Waits for an acknowledgement of a message.

public void WaitForAcknowledgment()

Remarks

This is primarily for use by JsonReporterMessageHandler so that it can wait for acknowledgment of messages when running in synchronous mode by the in-process runner. Other runner loggers running outside this context (and/or when not in synchronous automated mode) should NOOP for this.

WriteLine(string)

Writes a (non-colored) message. If Xunit.Runner.Common.ConsoleRunnerLogger.useColors is false, all ANSI-SGR sequences will be removed prior to writing.

public void WriteLine(string message)

Parameters

message string

Message to write

Remarks