Repository navigation
Description
We would like to have a LoggerMessage.Define() method that accepts up to 14 type args.
New API Proposal
public static partial class LoggerMessage
{
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }where Microsoft.Extensions.Logging.LogOptions only has the one bool flag SkipEnabledCheck below:
namespace Microsoft.Extensions.Logging
{
public class LogOptions
{
public bool SkipEnabledCheck { get; set; }
}
}The 6 new APIs below that were added in .NET 6 timeframe need to get updated as well.
It now makes sense to update to taking LogOptions instead of boolean skipEnabledCheck flag:
- public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, System.Exception?> Define<T1>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
+ public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, System.Exception?> Define<T1>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
- public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, System.Exception?> Define<T1, T2>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
+ public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, System.Exception?> Define<T1, T2>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
- public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, System.Exception?> Define<T1, T2, T3>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
+ public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, System.Exception?> Define<T1, T2, T3>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
- public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, System.Exception?> Define<T1, T2, T3, T4>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
+ public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, System.Exception?> Define<T1, T2, T3, T4>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
- public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, System.Exception?> Define<T1, T2, T3, T4, T5>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
+ public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, System.Exception?> Define<T1, T2, T3, T4, T5>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
- public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, System.Exception?> Define<T1, T2, T3, T4, T5, T6>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
+ public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, System.Exception?> Define<T1, T2, T3, T4, T5, T6>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
More info for motive: #50334 (comment)
New proposal adds 10 new overloads. To support up to 16 arguments because that is what Action allows as well.
Previous API Proposal
public static partial class LoggerMessage
{
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; }
}Older issue (#35060) added up to 6 overlods for Define, this issue adds up to 16.
The reason to add up to 16 is because Action itself takes up to 16 parameters: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Action.cs#L24
Motivation
We've had requests to add more overloads in the past as well (e.g. #35060) so there is community interest in adding these APIs.
Also, the compile-time source generation for logging, allows support arbitrary number of parameters in a message template. But the runtime capabilities provided by LoggerMessage.Define APIs today is limited to only 6 parameters.
Adding the above APIs helps keep a more coherent range of logging feature support between compile-time and runtime in the framework library. This way for the most frequently hit user scenarios (up to 16 arguments) the compile time implementation can remain intact with runtime as well.
Additional Information
- Link to logging generator: here
- Link to generated baseline code samples using the logging generator: here
Follow up proposal - Support Dynamic Log Levels
As a follow up to the API proposal above, we could consider the APIs below as well to allow supporting dynamic log levels using LoggerMessage.Define.
Note: The compile-time source generator supports dynamic log levels as a feature.
public static partial class LoggerMessage
{
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, System.Exception?> Define(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, System.Exception?> Define<T1>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, System.Exception?> Define<T1, T2>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, System.Exception?> Define<T1, T2, T3>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, System.Exception?> Define<T1, T2, T3, T4>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, System.Exception?> Define<T1, T2, T3, T4, T5>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, System.Exception?> Define<T1, T2, T3, T4, T5, T6>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, T7, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, T7, T8, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, T7, T8, T9, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel logLevel, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, System.Exception?> Define<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; }
}
Activity
bartonjs commentedon Apr 9, 2021
Video
We think there's not a scenario for this, and we shouldn't add it until there is one.
davidfowl commentedon Apr 9, 2021
Don't we want to add more than 6 though? Like 10?
maryamariyan commentedon Apr 29, 2021
Reopening this issue, with an update.
Updated the issue description with the new proposal.
The new proposal adds 10 new overloads.
GrabYourPitchforks commentedon Apr 29, 2021
This issue now covers two topics: changing the signature of the previously-approved 6.0 APIs; and adding new overloads to cover additional generic parameters. I suspect the first one will sail through fairly smoothly.
For the additional generic parameters, check Jeremy's comment at #50913 (comment). Is there new information that shows a need for 16 arguments? Something we wouldn't be able to get by adding, say, better low-allocation string interpolation overloads to the existing logging functions, which would allow them to scale up to arbitrary-arity inputs and would allow for short-circuiting when the given warning level is not enabled?
Also keep in mind that if you're using
Action<...>, you can't go beyond T14. You're already using two parameters for yourILoggerandExceptionargs.[-]Add LoggerMessage.Define overloads accepting up to 16 arguments.[/-][+]Add LoggerMessage.Define overloads accepting up to 14 arguments.[/+]maryamariyan commentedon Apr 29, 2021
updated
maryamariyan commentedon Apr 29, 2021
One of the comments were about why we are adding two overloads per number of arguments (one with the skipEnabledCheck and one without). Using the new proposal we only add one overload per message template argument count.
cc @geeknoid since he also pointed out that they have cases using more than 6 arguments.
maryamariyan commentedon Apr 29, 2021
The string interpolation feature does not yet have a completed design for structured logging (scheduled within the .NET 6 timeframe). For Microsoft.Extensions.Logging we prototyped it partially in this design doc. There is also some discussion with Serilog owner on this too here.
The goal here is to make sure the runtime capability keeps up with what we support with code gen. the string interpolation builder would still be code generated. So it probably would still make sense to add the above overloads regardless of where we end up with string interpolation feature.
bartonjs commentedon May 11, 2021
The new overloads need more work, @davidfowl has concerns about the return type, and some explosion.
The new LogOptions class should be LogDefineOptions
Updating the not-yet-released API:
namespace Microsoft.Extensions.Logging { public static partial class LoggerMessage { - public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, System.Exception?> Define<T1>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; } + public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, System.Exception?> Define<T1>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; } - public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, System.Exception?> Define<T1, T2>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; } + public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, System.Exception?> Define<T1, T2>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; } - public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, System.Exception?> Define<T1, T2, T3>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; } + public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, System.Exception?> Define<T1, T2, T3>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; } - public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, System.Exception?> Define<T1, T2, T3, T4>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; } + public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, System.Exception?> Define<T1, T2, T3, T4>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; } - public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, System.Exception?> Define<T1, T2, T3, T4, T5>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; } + public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, System.Exception?> Define<T1, T2, T3, T4, T5>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; } - public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, System.Exception?> Define<T1, T2, T3, T4, T5, T6>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, bool skipEnabledCheck) { throw null; } + public static System.Action<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, System.Exception?> Define<T1, T2, T3, T4, T5, T6>(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString, Microsoft.Extensions.Logging.LogOptions options) { throw null; } } }Change preview overloads, take LogDefineOptions
Update new `LoggerMessage.Define` APIs, to take `LogDefineOptions` (#…
maryamariyan commentedon Jul 12, 2021
Closing this issue in favor of #55525. We already covered updating new .NET 6.0 overloads to use
LogDefineOptions. The remainder of the work (support for more arguments) is scoped for .NET 7.0