Photomechanics API
SerilogExtensions Class Reference

Provides helper extensions to Serilog logging. More...

Static Public Member Functions

static LoggerConfiguration ByTransformingWithSubtypes< TValue > (this LoggerDestructuringConfiguration destructuringConfiguration, Func< TValue, Object > transformation)
 When destructuring objects, transform instances of the specified type with the provided function. Inheritance-aware. More...
 
static ILogger ForContextOf< T > (this ILogger logger, T loggerOwner)
 
static LoggerSuppressionToken SuppressLogging (ILogger logger)
 Get disposable token with new logger to suppress provided logger. More...
 
static Operation BeginOperation (this ILogger logger, String messageTemplate, params Object?[] args)
 Start logging timing operation.
 
static void LogTimingOf (this ILogger logger, Action action, String messageTemplate, params Object?[] args)
 Log timing of operation. In case of exception it will be caught and logged. This is version for synchronous actions.
 
static async Task LogTimingOf (this ILogger logger, Func< Task > asyncAction, String messageTemplate, params Object?[] args)
 Log timing of operation. In case of exception it will be caught and logged. This is version for asynchronous actions.
 
static async Task LogTimingOf (this ILogger logger, Func< Task > asyncAction, Func< Boolean > predicate, String messageTemplate, params Object?[] args)
 Log timing of operation. In case of exception it will be caught and logged. This is version for asynchronous actions. Successful completion will be logged only if provided predicate returns true.
 

Detailed Description

Provides helper extensions to Serilog logging.

Member Function Documentation

◆ ByTransformingWithSubtypes< TValue >()

static LoggerConfiguration SerilogExtensions.ByTransformingWithSubtypes< TValue > ( this LoggerDestructuringConfiguration  destructuringConfiguration,
Func< TValue, Object >  transformation 
)
static

When destructuring objects, transform instances of the specified type with the provided function. Inheritance-aware.

Parameters
destructuringConfigurationDestructuring configuration.
transformationFunction mapping instances of TValue to an alternative representation.
Template Parameters
TValueType of values to transform.
Returns
Configuration object allowing method chaining.
Exceptions
ArgumentNullException

◆ ForContextOf< T >()

static ILogger SerilogExtensions.ForContextOf< T > ( this ILogger  logger,
loggerOwner 
)
static

Parameters
logger
loggerOwner
Template Parameters
T
Returns
Type Constraints
T :notnull 
T :logger.ForContext 
T :Constants.SourceContextPropertyName 
T :$ 

◆ SuppressLogging()

static LoggerSuppressionToken SerilogExtensions.SuppressLogging ( ILogger  logger)
static

Get disposable token with new logger to suppress provided logger.

Provides wrapper around base logger that can be switched on and off. When disposed, disables this behavior so new log messages are no longer suppressed.