Table of Contents

Class FakeLogger

Namespace
adas_core.Test.Models
Assembly
adas-core.Test.dll

Represents a fake implementation of the ILogger interface, typically used as a test double to simulate logging behavior.

public class FakeLogger : ILogger
Inheritance
FakeLogger
Implements
ILogger
Inherited Members
Extension Methods

Properties

Messages

public List<string> Messages { get; }

Property Value

List<string>

Methods

ForContext(IEnumerable<ILogEventEnricher>)

Creates a logger context enriched with the specified Serilog.Core.ILogEventEnricher instances. In this implementation, the enrichers are not applied and the current Serilog.ILogger instance is returned unchanged.

public ILogger ForContext(IEnumerable<ILogEventEnricher> enrichers)

Parameters

enrichers IEnumerable<ILogEventEnricher>

The collection of enrichers intended to add contextual properties to log events.

Returns

ILogger

The current Serilog.ILogger instance, without the supplied enrichers applied.

ForContext(string, object?, bool)

Creates a logger context enriched with the specified property and value, returning the same logger instance.

public ILogger ForContext(string propertyName, object? value, bool destructureObjects = false)

Parameters

propertyName string

The name of the property to add to the logger context.

value object

The value associated with the property. Can be null.

destructureObjects bool

Indicates whether complex objects should be destructured. Defaults to false.

Returns

ILogger

The current Serilog.ILogger instance.

ForContext(Type)

Returns the current logger instance, ignoring the provided source type. Provides a no-op context enrichment for log messages.

public ILogger ForContext(Type source)

Parameters

source Type

The source type used to enrich the logger context.

Returns

ILogger

The current Serilog.ILogger instance.

ForContext<TSource>()

Creates a logger context associated with the specified source type by returning the current Serilog.ILogger instance.

public ILogger ForContext<TSource>()

Returns

ILogger

The current Serilog.ILogger instance.

Type Parameters

TSource

The source type used to enrich the logger context.

IsEnabled(LogEventLevel)

Determines whether logging is enabled for the specified log event level. Currently returns true unconditionally, allowing all log levels to be processed.

public bool IsEnabled(LogEventLevel level)

Parameters

level LogEventLevel

The log event level to evaluate.

Returns

bool

true if logging is enabled for the given level; otherwise, false.

Write(LogEvent)

Appends the rendered message of the provided log event to the internal messages collection.

public void Write(LogEvent logEvent)

Parameters

logEvent LogEvent

The log event whose rendered message will be added to the collection.

Write(LogEventLevel, Exception?, string, params object?[]?)

Captures a log entry by appending the formatted message to the internal Messages collection. When propertyValues is provided, the messageTemplate is formatted with those values; otherwise the template is stored as-is. If exception is not null, its message is appended as an additional entry.

public void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object?[]? propertyValues)

Parameters

level LogEventLevel

The severity level of the log event.

exception Exception

An optional exception whose message is recorded when not null.

messageTemplate string

The message template to log, used directly when propertyValues is null.

propertyValues object[]

Optional values to substitute into messageTemplate via string.Format.

Write(LogEventLevel, string, params object?[]?)

Writes a log message at the specified level to the internal messages collection, formatting it with the provided property values.

public void Write(LogEventLevel level, string messageTemplate, params object?[]? propertyValues)

Parameters

level LogEventLevel

The severity level of the log event.

messageTemplate string

The message template containing placeholders for the property values.

propertyValues object[]

An optional array of objects to format the message template. Can be null.

Write<T>(LogEventLevel, Exception?, string, T)

Writes a log entry by formatting the provided message template with the supplied property value and appending it to the Messages collection. If an exception is supplied, its message is also appended to the collection.

public void Write<T>(LogEventLevel level, Exception? exception, string messageTemplate, T propertyValue)

Parameters

level LogEventLevel

The severity level of the log event.

exception Exception

An optional exception whose message, when not null, is added to the Messages collection after the formatted message.

messageTemplate string

The message template string used to format the log entry.

propertyValue T

The value to be substituted into the message template.

Type Parameters

T

Write<T>(LogEventLevel, string, T)

Writes a log entry by formatting the provided message template with the given property value and adding it to the messages collection.

public void Write<T>(LogEventLevel level, string messageTemplate, T propertyValue)

Parameters

level LogEventLevel

The log event level associated with the entry being written.

messageTemplate string

The message template containing a format placeholder for the property value.

propertyValue T

The value to be inserted into the message template.

Type Parameters

T

The type of the property value to be substituted into the message template.