Table of Contents

Interface IGetsLogger

Namespace
CSF.Extensions.WebDriver
Assembly
CSF.Extensions.WebDriver.dll

Small service which provides a method for obtaining loggers.

public interface IGetsLogger

Remarks

This service is required in this library because we cannot use DI registration techniques to interrogate whether logging is already registered into DI. This library is intended to be used alongside the BoDi DI container, which is part of the Reqnroll BDD framework. In this scenario, BoDi is consumed via an adpater, to make it behave a little like IServiceCollection.

Unfortunately, because of limitations in BoDi's design, this is far from perfect (an LSP violation) and the resulting service collection throws from much of its functionality. One of these is the indexer and GetEnumerator() implementation upon the service collection. Those functions are the only viable way to determine whether logging has already been registered into DI (to avoid clobbering an existing DI registration), and they aren't available to us.

This interface and its internal visibility impl provide a workaround to that, which decides at resolution time whether a logging implementation was formally registered into DI. If it was then it is resolved from the container as usual. If it was not then a noop implementation of a logger is returned, to avoid throwing or returning null.

Methods

GetLogger<T>()

Gets a logger for the specified type.

ILogger<T> GetLogger<T>()

Returns

ILogger<T>

A logger implementation

Type Parameters

T

The type which intends to record log messages.