Skip to content

Commit

Permalink
Merge pull request #1357 from rob-earwaker/docs/default-destructuring…
Browse files Browse the repository at this point in the history
…-depth

Update summary for default destructuring depth
  • Loading branch information
nblumhardt committed Aug 31, 2019
2 parents f4c8798 + 0494601 commit 5c127cb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Serilog/Configuration/LoggerDestructuringConfiguration.cs
Expand Up @@ -137,9 +137,9 @@ public LoggerConfiguration ByTransforming<TValue>(Func<TValue, object> transform
}

/// <summary>
/// When destructuring objects, depth will be limited to 5 property traversals deep to
/// When destructuring objects, depth will be limited to 10 property traversals deep to
/// guard against ballooning space when recursive/cyclic structures are accidentally passed. To
/// increase this limit pass a higher value.
/// change this limit pass a new maximum depth.
/// </summary>
/// <param name="maximumDestructuringDepth">The maximum depth to use.</param>
/// <returns>Configuration object allowing method chaining.</returns>
Expand Down
29 changes: 29 additions & 0 deletions test/Serilog.Tests/LoggerConfigurationTests.cs
Expand Up @@ -262,6 +262,35 @@ public void EnrichersExecuteInConfigurationOrder()
Assert.True(enrichedPropertySeen);
}

[Fact]
public void MaximumDestructuringDepthDefaultIsEffective()
{
var x = new
{
Lvl01 = new
{
Lvl02 = new
{
Lvl03 = new
{
Lvl04 = new
{
Lvl05 = new
{
Lvl06 = new { Lvl07 = new { Lvl08 = new { Lvl09 = new { Lvl10 = "Lvl11" } } } }
}
}
}
}
}
};

var xs = LogAndGetAsString(x, conf => conf, "@");

Assert.Contains("Lvl10", xs);
Assert.DoesNotContain("Lvl11", xs);
}

[Fact]
public void MaximumDestructuringDepthIsEffective()
{
Expand Down

0 comments on commit 5c127cb

Please sign in to comment.