Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/Sentry/Internal/DefaultSentryStructuredLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ private protected override void CaptureLog(SentryLogLevel level, string template
var timestamp = _clock.GetUtcNow();
_hub.GetTraceIdAndSpanId(out var traceId, out var spanId);

string message;
try
{
message = string.Format(CultureInfo.InvariantCulture, template, parameters ?? []);
}
catch (FormatException e)
string message = template;
if (parameters is { Length: > 0 })
{
_options.DiagnosticLogger?.LogError(e, "Template string does not match the provided argument. The Log will be dropped.");
return;
try
{
message = string.Format(CultureInfo.InvariantCulture, template, parameters);
}
catch (FormatException e)
{
_options.DiagnosticLogger?.LogError(e, "Template string does not match the provided argument. The Log will be dropped.");
return;
}
}

ImmutableArray<KeyValuePair<string, object>> @params = default;
Expand Down
27 changes: 27 additions & 0 deletions test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@

_fixture.Hub.Received(0).CaptureEnvelope(Arg.Any<Envelope>());
}

[Theory]
[InlineData(SentryLogLevel.Trace)]
[InlineData(SentryLogLevel.Debug)]
[InlineData(SentryLogLevel.Info)]
[InlineData(SentryLogLevel.Warning)]
[InlineData(SentryLogLevel.Error)]
[InlineData(SentryLogLevel.Fatal)]
public void Log_WithoutParameters_DoesNotAttachTemplateAttribute(SentryLogLevel level)
{
_fixture.Options.Experimental.EnableLogs = true;

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / Build (net9.0)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / Build (net10.0)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / Build (net10.0)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-musl-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / ios-tests

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / ios-tests

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (linux-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-x64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (win-arm64)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / MSBuild

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / MSBuild

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / MSBuild

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / MSBuild

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / MSBuild

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / MSBuild

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 96 in test/Sentry.Tests/SentryStructuredLoggerTests.Format.cs

View workflow job for this annotation

GitHub Actions / .NET (macos)

'SentryOptions.ExperimentalSentryOptions' does not contain a definition for 'EnableLogs' and no accessible extension method 'EnableLogs' accepting a first argument of type 'SentryOptions.ExperimentalSentryOptions' could be found (are you missing a using directive or an assembly reference?)
var logger = _fixture.GetSut();

Envelope envelope = null!;
_fixture.Hub.CaptureEnvelope(Arg.Do<Envelope>(arg => envelope = arg));

logger.Log(level, "Message Text");
logger.Flush();

_fixture.Hub.Received(1).CaptureEnvelope(Arg.Any<Envelope>());
var log = envelope.ShouldContainSingleLog();

log.Level.Should().Be(level);
log.Message.Should().Be("Message Text");
log.Template.Should().BeNull();
log.Parameters.Should().BeEmpty();
}
}

file static class SentryStructuredLoggerExtensions
Expand Down
10 changes: 10 additions & 0 deletions test/Sentry.Tests/SentryStructuredLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,14 @@ public static void AssertLog(this SentryStructuredLoggerTests.Fixture fixture, S
{
return new KeyValuePair<string, object?>(name, value);
}

public static SentryLog ShouldContainSingleLog(this Envelope envelope)
{
var envelopeItem = envelope.Items.Should().ContainSingle().Which;
var serializable = envelopeItem.Payload.Should().BeOfType<JsonSerializable>().Which;
var log = serializable.Source.Should().BeOfType<StructuredLog>().Which;

log.Items.Length.Should().Be(1);
return log.Items[0];
}
}
Loading