Skip to content

Commit e43eeec

Browse files
committed
Refactor format provider handling in RichTextBoxSink options
1 parent 7a7d735 commit e43eeec

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Serilog.Sinks.RichTextBox.WinForms.Colored/RichTextBoxSinkLoggerConfigurationExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using Serilog.Sinks.RichTextBoxForms.Rendering;
2424
using Serilog.Sinks.RichTextBoxForms.Themes;
2525
using System;
26+
using System.Globalization;
2627
using System.Windows.Forms;
2728

2829
namespace Serilog
@@ -58,8 +59,9 @@ public static LoggerConfiguration RichTextBox(
5859
LoggingLevelSwitch? levelSwitch = null)
5960
{
6061
var appliedTheme = theme ?? ThemePresets.Literate;
61-
var renderer = new TemplateRenderer(appliedTheme, outputTemplate, formatProvider);
62-
var options = new RichTextBoxSinkOptions(appliedTheme, autoScroll, maxLogLines, outputTemplate, formatProvider);
62+
var appliedFormatProvider = formatProvider ?? CultureInfo.InvariantCulture;
63+
var renderer = new TemplateRenderer(appliedTheme, outputTemplate, appliedFormatProvider);
64+
var options = new RichTextBoxSinkOptions(appliedTheme, autoScroll, maxLogLines, outputTemplate, appliedFormatProvider);
6365
richTextBoxSink = new RichTextBoxSink(richTextBoxControl, options, renderer);
6466
return sinkConfiguration.Sink(richTextBoxSink, minimumLogEventLevel, levelSwitch);
6567
}

Serilog.Sinks.RichTextBox.WinForms.Colored/Sinks/RichTextBoxForms/RichTextBoxSinkOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
using Serilog.Sinks.RichTextBoxForms.Themes;
2020
using System;
21+
using System.Globalization;
2122

2223
namespace Serilog.Sinks.RichTextBoxForms
2324
{
@@ -46,7 +47,7 @@ public RichTextBoxSinkOptions(
4647
Theme = theme;
4748
MaxLogLines = maxLogLines;
4849
OutputTemplate = outputTemplate;
49-
FormatProvider = formatProvider;
50+
FormatProvider = formatProvider ?? CultureInfo.InvariantCulture;
5051
}
5152

5253
public bool AutoScroll { get; set; }

0 commit comments

Comments
 (0)