Table of Contents

Struct LogInterpolatedStringHandler

Namespace
OpenQA.Selenium.Internal.Logging
Assembly
Selenium.WebDriver.dll

Core interpolated string handler that defers string construction until the log level is confirmed enabled, avoiding unnecessary string allocations when logging is disabled.

public ref struct LogInterpolatedStringHandler
Inherited Members

Remarks

On net8.0 and later this delegates to System.Runtime.CompilerServices.DefaultInterpolatedStringHandler, which uses pooled character buffers and ISpanFormattable to avoid boxing of value-type arguments. On older target frameworks a System.Text.StringBuilder is used. All formatting is performed using InvariantCulture so log output is culture-independent.

Constructors

LogInterpolatedStringHandler(int, int, ILogger, LogEventLevel, out bool)

Initializes a new instance of the LogInterpolatedStringHandler struct.

public LogInterpolatedStringHandler(int literalLength, int formattedCount, ILogger logger, LogEventLevel level, out bool isEnabled)

Parameters

literalLength int

The number of literal characters in the interpolated string.

formattedCount int

The number of interpolation holes in the interpolated string.

logger ILogger

The logger to check for enabled status.

level LogEventLevel

The log event level to check.

isEnabled bool

On return, indicates whether logging is enabled for this level.

Methods

AppendFormatted<T>(T)

Appends a formatted value to the handler.

public void AppendFormatted<T>(T value)

Parameters

value T

The value to format and append.

Type Parameters

T

The type of the value to format.

AppendFormatted<T>(T, int)

Appends a formatted value with alignment to the handler.

public void AppendFormatted<T>(T value, int alignment)

Parameters

value T

The value to format and append.

alignment int

The alignment for the formatted value.

Type Parameters

T

The type of the value to format.

AppendFormatted<T>(T, int, string?)

Appends a formatted value with alignment and a format string to the handler.

public void AppendFormatted<T>(T value, int alignment, string? format)

Parameters

value T

The value to format and append.

alignment int

The alignment for the formatted value.

format string

The format string.

Type Parameters

T

The type of the value to format.

AppendFormatted<T>(T, string?)

Appends a formatted value with a format string to the handler.

public void AppendFormatted<T>(T value, string? format)

Parameters

value T

The value to format and append.

format string

The format string.

Type Parameters

T

The type of the value to format.

AppendLiteral(string)

Appends a literal string to the handler.

public void AppendLiteral(string s)

Parameters

s string

The literal string to append.