Skip to content

Commit 489be94

Browse files
authored
Merge pull request #136 from nblumhardt/fix-sequence-width-reporting
Report the number of escape characters formatted into themed sequence rendering
2 parents ac9edbe + bf45645 commit 489be94

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/Serilog.Sinks.Console/Sinks/SystemConsole/Formatting/ThemedJsonValueFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected override int VisitSequenceValue(ThemedValueFormatterState state, Seque
7070
}
7171

7272
delim = ", ";
73-
Visit(state.Nest(), sequence.Elements[index]);
73+
count += Visit(state.Nest(), sequence.Elements[index]);
7474
}
7575

7676
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))

src/Serilog.Sinks.Console/Sinks/SystemConsole/Output/ExceptionTokenRenderer.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ class ExceptionTokenRenderer : OutputTemplateTokenRenderer
2525

2626
readonly ConsoleTheme _theme;
2727

28-
public ExceptionTokenRenderer(ConsoleTheme theme, PropertyToken pt)
28+
public ExceptionTokenRenderer(ConsoleTheme theme)
2929
{
30-
_theme = theme;
31-
}
30+
_theme = theme;
31+
}
3232

3333
public override void Render(LogEvent logEvent, TextWriter output)
3434
{
35-
// Padding is never applied by this renderer.
36-
37-
if (logEvent.Exception is null)
38-
return;
39-
40-
var lines = new StringReader(logEvent.Exception.ToString());
41-
string? nextLine;
42-
while ((nextLine = lines.ReadLine()) != null)
43-
{
44-
var style = nextLine.StartsWith(StackFrameLinePrefix) ? ConsoleThemeStyle.SecondaryText : ConsoleThemeStyle.Text;
45-
var _ = 0;
46-
using (_theme.Apply(output, style, ref _))
47-
output.Write(nextLine);
48-
output.WriteLine();
49-
}
35+
// Padding is never applied by this renderer.
36+
37+
if (logEvent.Exception is null)
38+
return;
39+
40+
var lines = new StringReader(logEvent.Exception.ToString());
41+
string? nextLine;
42+
while ((nextLine = lines.ReadLine()) != null)
43+
{
44+
var style = nextLine.StartsWith(StackFrameLinePrefix) ? ConsoleThemeStyle.SecondaryText : ConsoleThemeStyle.Text;
45+
var _ = 0;
46+
using (_theme.Apply(output, style, ref _))
47+
output.Write(nextLine);
48+
output.WriteLine();
5049
}
50+
}
5151
}

src/Serilog.Sinks.Console/Sinks/SystemConsole/Output/OutputTemplateRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public OutputTemplateRenderer(ConsoleTheme theme, string outputTemplate, IFormat
6060
}
6161
else if (pt.PropertyName == OutputProperties.ExceptionPropertyName)
6262
{
63-
renderers.Add(new ExceptionTokenRenderer(theme, pt));
63+
renderers.Add(new ExceptionTokenRenderer(theme));
6464
}
6565
else if (pt.PropertyName == OutputProperties.MessagePropertyName)
6666
{

0 commit comments

Comments
 (0)