Skip to content

Commit 35f8f96

Browse files
committed
Use Serilog.Expressions where knowledge of the built-in @sp property is needed
1 parent 4e5bfa3 commit 35f8f96

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/SeqCli/Output/OutputFormatter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
using SeqCli.Ingestion;
22
using SeqCli.Levels;
33
using Serilog.Formatting;
4-
using Seq.Syntax.Templates;
4+
using Serilog.Templates;
55

66
namespace SeqCli.Output;
77

88
static class OutputFormatter
99
{
10+
// This is the only usage of Serilog.Expressions remaining in seqcli; the upstream Seq.Syntax doesn't yet support
11+
// the `@sp` property, because it needs to load on older Seq installs with older Serilog versions embedded in the
12+
// app runner. Once we've updated it, we can switch this to a Seq.Syntax template.
1013
internal static readonly ITextFormatter Json = new ExpressionTemplate(
1114
$"{{ {{@t, @mt, @l: coalesce({LevelMapping.SurrogateLevelProperty}, if @l = 'Information' then undefined() else @l), @x, @sp, @tr, @ps: coalesce({TraceConstants.ParentSpanIdProperty}, @ps), @st: coalesce({TraceConstants.SpanStartTimestampProperty}, @st), ..rest()}} }}\n"
1215
);

src/SeqCli/SeqCli.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<PackageReference Include="Destructurama.JsonNet" Version="2.0.1" />
3030
<PackageReference Include="newtonsoft.json" Version="13.0.3" />
3131
<PackageReference Include="Serilog" Version="3.1.1" />
32+
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
3233
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
3334
<PackageReference Include="Serilog.Formatting.Compact.Reader" Version="3.0.0" />
3435
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />

0 commit comments

Comments
 (0)