Skip to content

Commit cfe1703

Browse files
committed
ref(logs): reorder parameters
1 parent 92a3afd commit cfe1703

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

src/Sentry.Serilog/SentrySinkExtensions.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ public static class SentrySinkExtensions
1313
/// </summary>
1414
/// <param name="loggerConfiguration">The logger configuration .<seealso cref="LoggerSinkConfiguration"/></param>
1515
/// <param name="dsn">The Sentry DSN (required). <seealso cref="SentryOptions.Dsn"/></param>
16-
/// <param name="minimumEventLevel">Minimum log level to send an event. <seealso cref="SentrySerilogOptions.MinimumEventLevel"/></param>
1716
/// <param name="minimumBreadcrumbLevel">Minimum log level to record a breadcrumb. <seealso cref="SentrySerilogOptions.MinimumBreadcrumbLevel"/></param>
17+
/// <param name="minimumEventLevel">Minimum log level to send an event. <seealso cref="SentrySerilogOptions.MinimumEventLevel"/></param>
1818
/// <param name="formatProvider">The Serilog format provider. <seealso cref="IFormatProvider"/></param>
1919
/// <param name="textFormatter">The Serilog text formatter. <seealso cref="ITextFormatter"/></param>
20-
/// <param name="experimentalEnableLogs">Whether to send structured logs. <seealso cref="SentryOptions.SentryExperimentalOptions.EnableLogs"/></param>
2120
/// <param name="sendDefaultPii">Whether to include default Personal Identifiable information. <seealso cref="SentryOptions.SendDefaultPii"/></param>
2221
/// <param name="isEnvironmentUser">Whether to report the <see cref="System.Environment.UserName"/> as the User affected in the event. <seealso cref="SentryOptions.IsEnvironmentUser"/></param>
2322
/// <param name="serverName">Gets or sets the name of the server running the application. <seealso cref="SentryOptions.ServerName"/></param>
@@ -36,6 +35,7 @@ public static class SentrySinkExtensions
3635
/// <param name="reportAssembliesMode">What mode to use for reporting referenced assemblies in each event sent to sentry. Defaults to <see cref="Sentry.ReportAssembliesMode.Version"/></param>
3736
/// <param name="deduplicateMode">What modes to use for event automatic de-duplication. <seealso cref="SentryOptions.DeduplicateMode"/></param>
3837
/// <param name="defaultTags">Default tags to add to all events. <seealso cref="SentryOptions.DefaultTags"/></param>
38+
/// <param name="experimentalEnableLogs">Whether to send structured logs. <seealso cref="SentryOptions.SentryExperimentalOptions.EnableLogs"/></param>
3939
/// <returns><see cref="LoggerConfiguration"/></returns>
4040
/// <example>This sample shows how each item may be set from within a configuration file:
4141
/// <code>
@@ -52,7 +52,6 @@ public static class SentrySinkExtensions
5252
/// "minimumBreadcrumbLevel": "Verbose",
5353
/// "minimumEventLevel": "Error",
5454
/// "outputTemplate": "{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}/{ThreadId}) {Message}{NewLine}{Exception}",
55-
/// "experimentalEnableLogs": true,
5655
/// "sendDefaultPii": false,
5756
/// "isEnvironmentUser": false,
5857
/// "serverName": "MyServerName",
@@ -73,7 +72,8 @@ public static class SentrySinkExtensions
7372
/// "defaultTags": {
7473
/// "key-1", "value-1",
7574
/// "key-2", "value-2"
76-
/// }
75+
/// },
76+
/// "experimentalEnableLogs": true
7777
/// }
7878
/// }
7979
/// ]
@@ -88,7 +88,6 @@ public static LoggerConfiguration Sentry(
8888
LogEventLevel? minimumEventLevel = null,
8989
IFormatProvider? formatProvider = null,
9090
ITextFormatter? textFormatter = null,
91-
bool? experimentalEnableLogs = null,
9291
bool? sendDefaultPii = null,
9392
bool? isEnvironmentUser = null,
9493
string? serverName = null,
@@ -106,15 +105,15 @@ public static LoggerConfiguration Sentry(
106105
SentryLevel? diagnosticLevel = null,
107106
ReportAssembliesMode? reportAssembliesMode = null,
108107
DeduplicateMode? deduplicateMode = null,
109-
Dictionary<string, string>? defaultTags = null)
108+
Dictionary<string, string>? defaultTags = null,
109+
bool? experimentalEnableLogs = null)
110110
{
111111
return loggerConfiguration.Sentry(o => ConfigureSentrySerilogOptions(o,
112112
dsn,
113113
minimumEventLevel,
114114
minimumBreadcrumbLevel,
115115
formatProvider,
116116
textFormatter,
117-
experimentalEnableLogs,
118117
sendDefaultPii,
119118
isEnvironmentUser,
120119
serverName,
@@ -132,7 +131,8 @@ public static LoggerConfiguration Sentry(
132131
diagnosticLevel,
133132
reportAssembliesMode,
134133
deduplicateMode,
135-
defaultTags));
134+
defaultTags,
135+
experimentalEnableLogs));
136136
}
137137

138138
/// <summary>
@@ -186,7 +186,7 @@ public static LoggerConfiguration Sentry(
186186
minimumBreadcrumbLevel,
187187
formatProvider,
188188
textFormatter,
189-
experimentalEnableLogs));
189+
experimentalEnableLogs: experimentalEnableLogs));
190190
}
191191

192192
internal static void ConfigureSentrySerilogOptions(
@@ -196,7 +196,6 @@ internal static void ConfigureSentrySerilogOptions(
196196
LogEventLevel? minimumBreadcrumbLevel = null,
197197
IFormatProvider? formatProvider = null,
198198
ITextFormatter? textFormatter = null,
199-
bool? experimentalEnableLogs = null,
200199
bool? sendDefaultPii = null,
201200
bool? isEnvironmentUser = null,
202201
string? serverName = null,
@@ -214,7 +213,8 @@ internal static void ConfigureSentrySerilogOptions(
214213
SentryLevel? diagnosticLevel = null,
215214
ReportAssembliesMode? reportAssembliesMode = null,
216215
DeduplicateMode? deduplicateMode = null,
217-
Dictionary<string, string>? defaultTags = null)
216+
Dictionary<string, string>? defaultTags = null,
217+
bool? experimentalEnableLogs = null)
218218
{
219219
if (dsn is not null)
220220
{
@@ -241,11 +241,6 @@ internal static void ConfigureSentrySerilogOptions(
241241
sentrySerilogOptions.TextFormatter = textFormatter;
242242
}
243243

244-
if (experimentalEnableLogs.HasValue)
245-
{
246-
sentrySerilogOptions.Experimental.EnableLogs = experimentalEnableLogs.Value;
247-
}
248-
249244
if (sendDefaultPii.HasValue)
250245
{
251246
sentrySerilogOptions.SendDefaultPii = sendDefaultPii.Value;
@@ -331,6 +326,11 @@ internal static void ConfigureSentrySerilogOptions(
331326
sentrySerilogOptions.DeduplicateMode = deduplicateMode.Value;
332327
}
333328

329+
if (experimentalEnableLogs.HasValue)
330+
{
331+
sentrySerilogOptions.Experimental.EnableLogs = experimentalEnableLogs.Value;
332+
}
333+
334334
// Serilog-specific items
335335
sentrySerilogOptions.InitializeSdk = dsn is not null; // Inferred from the Sentry overload that is used
336336
if (defaultTags?.Count > 0)

test/Sentry.Serilog.Tests/SentrySerilogOptionsTests.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,4 @@ public void Ctor_MinimumEventLevel_Error()
1515
var sut = new SentrySerilogOptions();
1616
Assert.Equal(LogEventLevel.Error, sut.MinimumEventLevel);
1717
}
18-
19-
[Fact]
20-
public void Ctor_EnableLogs_False()
21-
{
22-
var sut = new SentrySerilogOptions();
23-
Assert.False(sut.Experimental.EnableLogs);
24-
}
2518
}

test/Sentry.Serilog.Tests/SentrySerilogSinkExtensionsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,14 @@ public void ConfigureSentrySerilogOptions_WithAllParameters_MakesAppropriateChan
9393
var sut = Fixture.GetSut();
9494

9595
SentrySinkExtensions.ConfigureSentrySerilogOptions(sut, _fixture.Dsn, _fixture.MinimumEventLevel,
96-
_fixture.MinimumBreadcrumbLevel, null, null, _fixture.ExperimentalEnableLogs, _fixture.SendDefaultPii,
96+
_fixture.MinimumBreadcrumbLevel, null, null, _fixture.SendDefaultPii,
9797
_fixture.IsEnvironmentUser, _fixture.ServerName, _fixture.AttachStackTrace, _fixture.MaxBreadcrumbs,
9898
_fixture.SampleRate, _fixture.Release, _fixture.Environment, _fixture.MaxQueueItems,
9999
_fixture.ShutdownTimeout, _fixture.DecompressionMethods, _fixture.RequestBodyCompressionLevel,
100100
_fixture.RequestBodyCompressionBuffered, _fixture.Debug, _fixture.DiagnosticLevel,
101-
_fixture.ReportAssembliesMode, _fixture.DeduplicateMode);
101+
_fixture.ReportAssembliesMode, _fixture.DeduplicateMode, null, _fixture.ExperimentalEnableLogs);
102102

103103
// Compare individual properties
104-
Assert.Equal(_fixture.ExperimentalEnableLogs, sut.Experimental.EnableLogs);
105104
Assert.Equal(_fixture.SendDefaultPii, sut.SendDefaultPii);
106105
Assert.Equal(_fixture.IsEnvironmentUser, sut.IsEnvironmentUser);
107106
Assert.Equal(_fixture.ServerName, sut.ServerName);
@@ -120,6 +119,7 @@ public void ConfigureSentrySerilogOptions_WithAllParameters_MakesAppropriateChan
120119
Assert.Equal(_fixture.DiagnosticLevel, sut.DiagnosticLevel);
121120
Assert.Equal(_fixture.ReportAssembliesMode, sut.ReportAssembliesMode);
122121
Assert.Equal(_fixture.DeduplicateMode, sut.DeduplicateMode);
122+
Assert.Equal(_fixture.ExperimentalEnableLogs, sut.Experimental.EnableLogs);
123123
Assert.True(sut.InitializeSdk);
124124
Assert.Equal(_fixture.MinimumEventLevel, sut.MinimumEventLevel);
125125
Assert.Equal(_fixture.MinimumBreadcrumbLevel, sut.MinimumBreadcrumbLevel);

0 commit comments

Comments
 (0)