Skip to content

Request for Logging Internals to be public again #35060

Closed

Description

@JakenVeina

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 internal LogValuesFormatter 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.

Activity

  1. davidfowl commented on Apr 6, 2020

    @davidfowl
    Member

    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?

  2. JakenVeina commented on Apr 7, 2020

    @JakenVeina
    ContributorAuthor

    Certainly.

  3. maryamariyan commented on Apr 16, 2020

    @maryamariyan
    Contributor

    @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.

  4. maryamariyan commented on Apr 16, 2020

    @maryamariyan
    Contributor

    I just noticed your PR :)

  5. added
    untriaged
    on Apr 16, 2020
  6. added
    help wanted
    and removed
    untriaged
    on Apr 16, 2020
  7. added this to the 5.0 milestone on Apr 16, 2020
  8. 4 remaining items

  9. added
    blocking
    on Jul 8, 2020
  10. added
    api-approved
    and removed
    api-ready-for-review
    blocking
    on Jul 9, 2020
  11. bartonjs commented on Jul 9, 2020

    @bartonjs
    Member

    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.

        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; }
        }
  12. JakenVeina commented on Jul 9, 2020

    @JakenVeina
    ContributorAuthor

    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.

  13. maryamariyan commented on Jul 29, 2020

    @maryamariyan
    Contributor

    @JakenVeina I see you originally had a PR prepared for this.
    Were you thinking of reviving your PR with the final approved APIs?

  14. JakenVeina commented on Aug 5, 2020

    @JakenVeina
    ContributorAuthor

    Yes, definitely. I'll see if I can get it re-worked this weekend.

  15. maryamariyan commented on Aug 7, 2020

    @maryamariyan
    Contributor

    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.

  16. danmoseley commented on Aug 7, 2020

    @danmoseley
    Contributor

    We branch on Aug 17th - I'm guessing midday, maybe later though.

  17. JakenVeina commented on Aug 8, 2020

    @JakenVeina
    ContributorAuthor

    I've force-pushed an update to my fork. You should be able to re-open #34741.

  18. maryamariyan commented on Aug 8, 2020

    @maryamariyan
    Contributor

    @JakenVeina I doubt reopening would work and it wouldn't get the updated changes. Could you please open a new PR instead?

  19. JakenVeina commented on Aug 8, 2020

    @JakenVeina
    ContributorAuthor

    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.

  20. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedarea-Extensions-Logginghelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions