Skip to content

Commit

Permalink
Adjust class names and method description
Browse files Browse the repository at this point in the history
In accordance with review input.
  • Loading branch information
pardahlman committed Oct 10, 2017
1 parent 23f7710 commit 4073104
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
namespace Serilog
{
/// <summary>
/// Extension method 'ForContext' for ILogger.
/// Extends <see cref="ILogger" /> with additional methods.
/// </summary>
public static class ForContextExtension
public static class LoggerExtensions
{
/// <summary>
/// Create a logger that enriches log events with the specified property based on log event level.
/// Create a logger that enriches log events when the specified level is enabled.
/// </summary>
/// <typeparam name="TValue"> The type of the property value. </typeparam>
/// <param name="logger">The logger</param>
/// <param name="logger">The logger.</param>
/// <param name="level">The log event level used to determine if log is enriched with property.</param>
/// <param name="propertyName">The name of the property. Must be non-empty.</param>
/// <param name="value">The property value.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Serilog.Tests.Core
{
public class ForContextExtensionsTests
public class LoggerExtensionsTests
{
[Theory]
[InlineData(LogEventLevel.Debug, LogEventLevel.Debug)]
Expand All @@ -15,7 +15,6 @@ public class ForContextExtensionsTests
[InlineData(LogEventLevel.Debug, LogEventLevel.Warning)]
public void ShouldEnrichLogEventWhenLevelIsSameOrHigherThanMinLevel(LogEventLevel logMinLevel, LogEventLevel propertLogLevel)
{
// Arrange
var propValue = Guid.NewGuid();
var propKey = Some.String();
var sink = new CollectingSink();
Expand All @@ -24,11 +23,9 @@ public void ShouldEnrichLogEventWhenLevelIsSameOrHigherThanMinLevel(LogEventLeve
.WriteTo.Sink(sink)
.CreateLogger();

// Act
logger.ForContext(propertLogLevel, propKey, propValue)
.Write(logMinLevel, string.Empty);

// Assert
Assert.True(sink.SingleEvent.Properties.ContainsKey(propKey));
Assert.Equal(sink.SingleEvent.Properties[propKey].LiteralValue(), propValue);
}
Expand All @@ -41,7 +38,6 @@ public void ShouldEnrichLogEventWhenLevelIsSameOrHigherThanMinLevel(LogEventLeve
[InlineData(LogEventLevel.Fatal, LogEventLevel.Error)]
public void ShouldNotEnrichLogEventsWhenMinLevelIsHigherThanProvidedLogLevel(LogEventLevel logMinLevel, LogEventLevel propertLogLevel)
{
// Arrange
var propValue = Guid.NewGuid();
var propKey = Some.String();
var sink = new CollectingSink();
Expand All @@ -50,11 +46,9 @@ public void ShouldNotEnrichLogEventsWhenMinLevelIsHigherThanProvidedLogLevel(Log
.WriteTo.Sink(sink)
.CreateLogger();

// Act
logger.ForContext(propertLogLevel, propKey, propValue)
.Write(logMinLevel, string.Empty);

// Assert
Assert.True(!sink.SingleEvent.Properties.ContainsKey(propKey));
}
}
Expand Down

0 comments on commit 4073104

Please sign in to comment.