-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request for Logging Internals to be public again #35060
Comments
This sounds reasonable.Would you like to send a PR? |
Certainly. |
…up to 8, like elsewhere). Resolves https://github.com/dotnet/extensions/issues/3010
@JakenVeina please note you can now find the Logging source code in the dotnet/runtime repository. You might want to check these instruction links below:
I'll transfer this issue to runtime repo now. |
I just noticed your PR :) |
@JakenVeina, the runtime repo guidelines require us to go through an API review process. Looking at the existing APIs on LoggerMessage we see Define has more overloads than DefineScope. public static partial class LoggerMessage
{
public static System.Func<Microsoft.Extensions.Logging.ILogger, System.IDisposable> DefineScope(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, System.IDisposable> DefineScope<T1>(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, System.IDisposable> DefineScope<T1, T2>(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, System.IDisposable> DefineScope<T1, T2, T3>(string formatString) { throw null; }
public static System.Action<Microsoft.Extensions.Logging.ILogger, System.Exception> Define(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, string formatString) { 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) { 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) { 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) { 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) { 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) { 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) { throw null; }
} The missing ones you are proposing are: ...
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, System.IDisposable> DefineScope<T1, T2, T3, T4>(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, System.IDisposable> DefineScope<T1, T2, T3, T4, T5>(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, System.IDisposable> DefineScope<T1, T2, T3, T4, T5, T6>(string formatString) { throw null; }
... The above look reasonable. But looking at your PR, I see you are also proposing to added more overloads, to take up to 8 arg types. Regarding these other APIs, why the magic number 8? Is there a strong reason to have 8 and not just stick to existing 6? Referring to: public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, System.IDisposable> DefineScope<T1, T2, T3, T4, T5, T6, T7>(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, T7, T8, System.IDisposable> DefineScope<T1, T2, T3, T4, T5, T6, T7, T8>(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) { 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; }
|
No particular reason for 8, other than that's the "magic number" used elsewhere in the framework. E.G. |
Adding the DefineScope T4-T6 for parity is approved. If you want to add further ones, that's also approved, but in the review the comments were "why stop at 8?" and "do we need 7 and 8?". If there's need for this, then they're approved. If not, then maybe hold off. public static partial class LoggerMessage
{
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, System.IDisposable> DefineScope<T1, T2, T3, T4>(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, System.IDisposable> DefineScope<T1, T2, T3, T4, T5>(string formatString) { throw null; }
public static System.Func<Microsoft.Extensions.Logging.ILogger, T1, T2, T3, T4, T5, T6, System.IDisposable> DefineScope<T1, T2, T3, T4, T5, T6>(string formatString) { throw null; }
} |
That's a fair analysis. I can trim the T7 and T8 overloads out of the PR. After watching the video, I will go ahead and clarify the original request: The current Here's the commit that changed these from |
@JakenVeina I see you originally had a PR prepared for this. |
Yes, definitely. I'll see if I can get it re-worked this weekend. |
Thanks for contributing @JakenVeina. If we wanted to get this in for 5.0 the deadline would be August 18 I believe. It would be good if we could get this merged in before that time. |
We branch on Aug 17th - I'm guessing midday, maybe later though. |
I've force-pushed an update to my fork. You should be able to re-open #34741. |
@JakenVeina I doubt reopening would work and it wouldn't get the updated changes. Could you please open a new PR instead? |
Normally, that would work for me. I guess since it's already closed, github stops listening for changes on the forked branch. Regardless. New PR submitted. |
Use case: I'd like to have a
LoggerMessage.Define()
method that accepts more than 5 type args. I'm perfectly happy to implement this myself, by just copying how the others are done, in my own project, and adding more type args. However, the existing implementations rely on theinternal
LogValuesFormatter
class, which used to bepublic
within a.Internals
namespace.For now, my solution is simply to copy/paste the entire
LogValuesFormatter
class into my own project, which just seems like a waste.Alternatively, could we simply get
LoggerMessage.Define()
methods that take more type args? Perhaps up to 8, likeAction<T>
,Func<T>
,ValueTuple<T>
etc? Is there some particular performance reason that more than 5 type args would be disadvantageous?I'm happy to PR this myself, so long as no one is opposed to the change.
The text was updated successfully, but these errors were encountered: