Skip to content

Commit 97995a8

Browse files
committed
docs(logs): add XML comments indicating that logs will be ignored on delegate exceptions
1 parent 69678ce commit 97995a8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Sentry/SentryOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ public void SetBeforeBreadcrumb(Func<Breadcrumb, Breadcrumb?> beforeBreadcrumb)
534534

535535
/// <summary>
536536
/// Sets a callback function to be invoked before sending the log to Sentry.
537+
/// When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.
537538
/// <para>This API is experimental and it may change in the future.</para>
538539
/// </summary>
539540
/// <remarks>

src/Sentry/SentryStructuredLogger.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ internal SentryStructuredLogger(IHub hub, IInternalScopeManager? scopeManager, S
4040
/// Creates and sends a structured log to Sentry, with severity <see cref="SentryLogLevel.Trace"/>, when enabled and sampled.
4141
/// <para>This API is experimental and it may change in the future.</para>
4242
/// </summary>
43+
/// <param name="template">A formattable <see langword="string"/>. When incompatible with the <paramref name="parameters"/>, the log will not be captured. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
44+
/// <param name="parameters">The arguments to the <paramref name="template"/>. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
45+
/// <param name="configureLog">A delegate to set attributes on the <see cref="SentryLog"/>. When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.</param>
4346
public void LogTrace(string template, object[]? parameters = null, Action<SentryLog>? configureLog = null)
4447
{
4548
if (IsEnabled)
@@ -52,6 +55,9 @@ public void LogTrace(string template, object[]? parameters = null, Action<Sentry
5255
/// Creates and sends a structured log to Sentry, with severity <see cref="SentryLogLevel.Debug"/>, when enabled and sampled.
5356
/// <para>This API is experimental and it may change in the future.</para>
5457
/// </summary>
58+
/// <param name="template">A formattable <see langword="string"/>. When incompatible with the <paramref name="parameters"/>, the log will not be captured. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
59+
/// <param name="parameters">The arguments to the <paramref name="template"/>. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
60+
/// <param name="configureLog">A delegate to set attributes on the <see cref="SentryLog"/>. When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.</param>
5561
[Experimental(DiagnosticId.ExperimentalFeature)]
5662
public void LogDebug(string template, object[]? parameters = null, Action<SentryLog>? configureLog = null)
5763
{
@@ -65,6 +71,9 @@ public void LogDebug(string template, object[]? parameters = null, Action<Sentry
6571
/// Creates and sends a structured log to Sentry, with severity <see cref="SentryLogLevel.Info"/>, when enabled and sampled.
6672
/// <para>This API is experimental and it may change in the future.</para>
6773
/// </summary>
74+
/// <param name="template">A formattable <see langword="string"/>. When incompatible with the <paramref name="parameters"/>, the log will not be captured. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
75+
/// <param name="parameters">The arguments to the <paramref name="template"/>. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
76+
/// <param name="configureLog">A delegate to set attributes on the <see cref="SentryLog"/>. When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.</param>
6877
[Experimental(DiagnosticId.ExperimentalFeature)]
6978
public void LogInfo(string template, object[]? parameters = null, Action<SentryLog>? configureLog = null)
7079
{
@@ -78,6 +87,9 @@ public void LogInfo(string template, object[]? parameters = null, Action<SentryL
7887
/// Creates and sends a structured log to Sentry, with severity <see cref="SentryLogLevel.Warning"/>, when enabled and sampled.
7988
/// <para>This API is experimental and it may change in the future.</para>
8089
/// </summary>
90+
/// <param name="template">A formattable <see langword="string"/>. When incompatible with the <paramref name="parameters"/>, the log will not be captured. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
91+
/// <param name="parameters">The arguments to the <paramref name="template"/>. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
92+
/// <param name="configureLog">A delegate to set attributes on the <see cref="SentryLog"/>. When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.</param>
8193
[Experimental(DiagnosticId.ExperimentalFeature)]
8294
public void LogWarning(string template, object[]? parameters = null, Action<SentryLog>? configureLog = null)
8395
{
@@ -91,6 +103,9 @@ public void LogWarning(string template, object[]? parameters = null, Action<Sent
91103
/// Creates and sends a structured log to Sentry, with severity <see cref="SentryLogLevel.Error"/>, when enabled and sampled.
92104
/// <para>This API is experimental and it may change in the future.</para>
93105
/// </summary>
106+
/// <param name="template">A formattable <see langword="string"/>. When incompatible with the <paramref name="parameters"/>, the log will not be captured. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
107+
/// <param name="parameters">The arguments to the <paramref name="template"/>. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
108+
/// <param name="configureLog">A delegate to set attributes on the <see cref="SentryLog"/>. When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.</param>
94109
[Experimental(DiagnosticId.ExperimentalFeature)]
95110
public void LogError(string template, object[]? parameters = null, Action<SentryLog>? configureLog = null)
96111
{
@@ -104,6 +119,9 @@ public void LogError(string template, object[]? parameters = null, Action<Sentry
104119
/// Creates and sends a structured log to Sentry, with severity <see cref="SentryLogLevel.Fatal"/>, when enabled and sampled.
105120
/// <para>This API is experimental and it may change in the future.</para>
106121
/// </summary>
122+
/// <param name="template">A formattable <see langword="string"/>. When incompatible with the <paramref name="parameters"/>, the log will not be captured. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
123+
/// <param name="parameters">The arguments to the <paramref name="template"/>. See <see href="https://learn.microsoft.com/dotnet/api/system.string.format">System.String.Format</see>.</param>
124+
/// <param name="configureLog">A delegate to set attributes on the <see cref="SentryLog"/>. When the delegate throws an <see cref="Exception"/> during invocation, the log will not be captured.</param>
107125
[Experimental(DiagnosticId.ExperimentalFeature)]
108126
public void LogFatal(string template, object[]? parameters = null, Action<SentryLog>? configureLog = null)
109127
{
@@ -115,7 +133,7 @@ public void LogFatal(string template, object[]? parameters = null, Action<Sentry
115133

116134
private void CaptureLog(SentryLogLevel level, string template, object[]? parameters, Action<SentryLog>? configureLog)
117135
{
118-
Debug.Assert(_options is not null);
136+
Debug.Assert(IsEnabled);
119137

120138
var timestamp = _clock.GetUtcNow();
121139

0 commit comments

Comments
 (0)