Class EventDefinition<TParam1, TParam2, TParam3>
- Namespace
- Microsoft.EntityFrameworkCore.Diagnostics
- Assembly
- Microsoft.EntityFrameworkCore.dll
Defines metadata for an event with three parameters and a cached delegate to log the event with reduced allocations.
public class EventDefinition<TParam1, TParam2, TParam3> : EventDefinitionBase
Type Parameters
TParam1
TParam2
TParam3
- Inheritance
-
EventDefinition<TParam1, TParam2, TParam3>
- Inherited Members
Remarks
See Implementation of database providers and extensions for more information and examples.
Constructors
EventDefinition(ILoggingOptions, EventId, LogLevel, string, Func<LogLevel, Action<ILogger, TParam1, TParam2, TParam3, Exception?>>)
Creates an event definition instance.
public EventDefinition(ILoggingOptions loggingOptions, EventId eventId, LogLevel level, string eventIdCode, Func<LogLevel, Action<ILogger, TParam1, TParam2, TParam3, Exception?>> logActionFunc)
Parameters
loggingOptions
ILoggingOptionsLogging options.
eventId
EventIdThe EventId.
level
LogLevelThe LogLevel at which the event will be logged.
eventIdCode
stringA string representing the code that should be passed to ConfigureWarnings(Action<WarningsConfigurationBuilder>).
logActionFunc
Func<LogLevel, Action<ILogger, TParam1, TParam2, TParam3, Exception>>Function to create a cached delegate for logging the event.
Methods
GenerateMessage(TParam1, TParam2, TParam3, Exception?)
Generates the message that would be logged without logging it. Typically used for throwing an exception in warning-as-error cases.
public virtual string GenerateMessage(TParam1 arg1, TParam2 arg2, TParam3 arg3, Exception? exception = null)
Parameters
arg1
TParam1The first message argument.
arg2
TParam2The second message argument.
arg3
TParam3The third message argument.
exception
ExceptionOptional exception associated with this event.
Returns
- string
The message string.
Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory>, TParam1, TParam2, TParam3, Exception?)
Logs the event, or throws if the event has been configured to be treated as an error.
public virtual void Log<TLoggerCategory>(IDiagnosticsLogger<TLoggerCategory> logger, TParam1 arg1, TParam2 arg2, TParam3 arg3, Exception? exception = null) where TLoggerCategory : LoggerCategory<TLoggerCategory>, new()
Parameters
logger
IDiagnosticsLogger<TLoggerCategory>The logger to which the event should be logged.
arg1
TParam1The first message argument.
arg2
TParam2The second message argument.
arg3
TParam3The third message argument.
exception
ExceptionOptional exception associated with the event.
Type Parameters
TLoggerCategory
The DbLoggerCategory.