Skip to content

Commit 13ff836

Browse files
committed
Trivial sample updates
1 parent 9d7b013 commit 13ff836

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

example/Sample/Program.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@
22

33
namespace Sample
44
{
5-
public class Program
5+
public static class Program
66
{
7-
public static void Main(string[] args)
7+
public static void Main()
88
{
9-
var expr = "@Level = 'Information' and AppId is not null and Items[?] like 'C%'";
9+
const string expr = "@Level = 'Information' and AppId is not null and Items[?] like 'C%'";
1010

11-
Log.Logger = new LoggerConfiguration()
11+
using var log = new LoggerConfiguration()
1212
.Enrich.WithProperty("AppId", 10)
1313
.Filter.ByIncludingOnly(expr)
14-
.WriteTo.LiterateConsole()
14+
.WriteTo.Console()
1515
.CreateLogger();
1616

17-
Log.Information("Cart contains {@Items}", new[] { "Tea", "Coffee" });
18-
Log.Warning("Cart contains {@Items}", new[] { "Tea", "Coffee" });
19-
Log.Information("Cart contains {@Items}", new[] { "Apricots" });
20-
Log.Information("Cart contains {@Items}", new[] { "Peanuts", "Chocolate" });
21-
22-
Log.CloseAndFlush();
17+
log.Information("Cart contains {@Items}", new[] { "Tea", "Coffee" });
18+
log.Warning("Cart contains {@Items}", new[] { "Tea", "Coffee" });
19+
log.Information("Cart contains {@Items}", new[] { "Apricots" });
20+
log.Information("Cart contains {@Items}", new[] { "Peanuts", "Chocolate" });
2321
}
2422
}
2523
}

example/Sample/Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Serilog.Sinks.Literate" Version="2.0.0" />
9+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

src/Serilog.Expressions/Expressions/LoggingFilterSwitch.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System;
1616
using Serilog.Core;
1717
using Serilog.Events;
18+
using Serilog.Expressions.Runtime;
1819

1920
namespace Serilog.Expressions
2021
{
@@ -81,7 +82,7 @@ public bool IsEnabled(LogEvent logEvent)
8182
if (filter == null)
8283
return true;
8384

84-
return true.Equals((filter.Item2(logEvent) as ScalarValue)?.Value);
85+
return Coerce.True(filter.Item2(logEvent));
8586
}
8687

8788
/// <inheritdoc/>

0 commit comments

Comments
 (0)