Class LoggingExtensions
- Namespace
- WindowSill.API
- Assembly
- WindowSill.API.dll
Provides extension methods for logging.
public static class LoggingExtensions
- Inheritance
-
LoggingExtensions
- Inherited Members
Methods
Log(Type)
Creates an instance of ILogger for the specified type.
public static ILogger Log(this Type forType)
Parameters
forTypeTypeThe type to create the logger for.
Returns
Log<T>(T)
Creates an instance of ILogger for the given object's type.
public static ILogger Log<T>(this T instance)
Parameters
instanceTThe object instance.
Returns
Type Parameters
TThe type of the object.
MeasureDuration(ILogger, string?)
Measures the duration of an operation and logs the result when the operation completes.
public static DurationLogger MeasureDuration(this ILogger logger, string? measurementName = null)
Parameters
loggerILoggerThe ILogger instance used to log the duration.
measurementNamestringThe name of the operation being measured. Defaults to the caller's member name if not specified.
Returns
- DurationLogger
A DurationLogger instance that logs the duration of the operation when disposed.
Remarks
This method is typically used to measure and log the execution time of a code block. The
returned DurationLogger should be used within a using statement to ensure proper
disposal.