You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Request for Logging Internals to be public again #35060
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 the internalLogValuesFormatter class, which used to be public 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, like Action<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.
Alternatively, could we simply get LoggerMessage.Define() methods that take more type args? Perhaps up to 8, like Action, Func, ValueTuple etc? Is there some particular performance reason that more than 5 type args would be disadvantageous?
This sounds reasonable.Would you like to send a PR?
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.
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: LoggerMessage.Create() and LoggerMessage.BeginScope() are not the methods that used to be internal. There actually used to be a namespace Microsoft.Extensions.Logging.Abstractions.Internal that contained a few public types. Most significantly, they contained the LogMessageFormatter type, which is actually where a lot of the logic is that powers the LoggerMessage.Create() and LoggerMessage.BeginScope() methods. My original thought was to just make these types public again, so that someone who needs more type args than what's available has an easier time just implementing their own methods.
The current internal version of LogMessageFormatter can be seen here.
Here's the commit that changed these from public to internal.
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.
Activity
davidfowl commentedon Apr 6, 2020
This sounds reasonable.Would you like to send a PR?
JakenVeina commentedon Apr 7, 2020
Certainly.
maryamariyan commentedon Apr 16, 2020
@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.
maryamariyan commentedon Apr 16, 2020
I just noticed your PR :)
4 remaining items
bartonjs commentedon Jul 9, 2020
Video
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.
JakenVeina commentedon Jul 9, 2020
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:
LoggerMessage.Create()andLoggerMessage.BeginScope()are not the methods that used to beinternal. There actually used to be a namespaceMicrosoft.Extensions.Logging.Abstractions.Internalthat contained a fewpublictypes. Most significantly, they contained theLogMessageFormattertype, which is actually where a lot of the logic is that powers theLoggerMessage.Create()andLoggerMessage.BeginScope()methods. My original thought was to just make these typespublicagain, so that someone who needs more type args than what's available has an easier time just implementing their own methods.The current
internalversion ofLogMessageFormattercan be seen here.Here's the commit that changed these from
publictointernal.maryamariyan commentedon Jul 29, 2020
@JakenVeina I see you originally had a PR prepared for this.
Were you thinking of reviving your PR with the final approved APIs?
JakenVeina commentedon Aug 5, 2020
Yes, definitely. I'll see if I can get it re-worked this weekend.
maryamariyan commentedon Aug 7, 2020
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.
danmoseley commentedon Aug 7, 2020
We branch on Aug 17th - I'm guessing midday, maybe later though.
JakenVeina commentedon Aug 8, 2020
I've force-pushed an update to my fork. You should be able to re-open #34741.
maryamariyan commentedon Aug 8, 2020
@JakenVeina I doubt reopening would work and it wouldn't get the updated changes. Could you please open a new PR instead?
JakenVeina commentedon Aug 8, 2020
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.