Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Add more overloads to LoggerMessage.Define #296

Closed
wants to merge 1 commit into from

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Nov 18, 2015

@dnfclas
Copy link

dnfclas commented Nov 18, 2015

Hi @pakrym, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

/// <param name="eventId">The event id</param>
/// <param name="formatString">The named format string</param>
/// <returns>A delegate which when invoked creates a log message.</returns>
public static Action<ILogger, Exception> Define(LogLevel logLevel, int eventId, string formatString)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extension should not be required as the intention of the extensions in this file is to optimize for the scenarios where we pass parameters to the format string (where as here we do not pass any)...

Example:

public static void OrderPlaced(this ILogger logger)
{
    if (logger.IsEnabled(LogLevel.Information)
    { 
        logger.LogInformation(eventId: 10, "Order placed");
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but we get LoggingExtensions with two usage patterns inside which doesn't look good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kichalla I said it was ok 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kichalla in this particular case it's more about consistency and not any actual perf concern.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound good...I agree.

@Eilon
Copy link
Contributor

Eilon commented Nov 18, 2015

This addresses this issue: #272


public override string ToString() => _formatter.Format(ToArray());
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 extra lines!

@Eilon
Copy link
Contributor

Eilon commented Nov 18, 2015

Is it possible to add at least a basic test for these?

@pakrym
Copy link
Contributor Author

pakrym commented Nov 18, 2015

@Eilon will do

@pakrym
Copy link
Contributor Author

pakrym commented Nov 18, 2015

🆙 📅

@@ -162,6 +163,48 @@ public void LogScope_WithThreeParameters()
actualLogValues.ToString());
}

[Theory]
[MemberData(nameof(LogMessagesData))]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space :trollface:

@Eilon
Copy link
Contributor

Eilon commented Nov 18, 2015

:shipit: after code formatting.

@pakrym pakrym force-pushed the pakrym/more-overloads branch from 9a3ba74 to 646bb6e Compare November 18, 2015 17:29
@pakrym pakrym closed this Nov 18, 2015
@pakrym pakrym deleted the pakrym/more-overloads branch November 6, 2018 22:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants