Skip to content

Commit b0da783

Browse files
authored
Redact constants that get inlined from variables into query in log (#35724)
1 parent 9d3dcc5 commit b0da783

File tree

40 files changed

+559
-87
lines changed

40 files changed

+559
-87
lines changed

Diff for: src/EFCore.Relational/Diagnostics/CommandEndEventData.cs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class CommandEndEventData : CommandEventData
1919
/// <param name="messageGenerator">A delegate that generates a log message for this event.</param>
2020
/// <param name="connection">The <see cref="DbConnection" /> being used.</param>
2121
/// <param name="command">The <see cref="DbCommand" />.</param>
22+
/// <param name="logCommandText">The command text that can be logged.</param>
2223
/// <param name="context">The <see cref="DbContext" /> currently being used, to null if not known.</param>
2324
/// <param name="executeMethod">The <see cref="DbCommand" /> method.</param>
2425
/// <param name="commandId">A correlation ID that identifies the <see cref="DbCommand" /> instance being used.</param>
@@ -33,6 +34,7 @@ public CommandEndEventData(
3334
Func<EventDefinitionBase, EventData, string> messageGenerator,
3435
DbConnection connection,
3536
DbCommand command,
37+
string logCommandText,
3638
DbContext? context,
3739
DbCommandMethod executeMethod,
3840
Guid commandId,
@@ -47,6 +49,7 @@ public CommandEndEventData(
4749
messageGenerator,
4850
connection,
4951
command,
52+
logCommandText,
5053
context,
5154
executeMethod,
5255
commandId,

Diff for: src/EFCore.Relational/Diagnostics/CommandErrorEventData.cs

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class CommandErrorEventData : CommandEndEventData, IErrorEventData
1818
/// <param name="messageGenerator">A delegate that generates a log message for this event.</param>
1919
/// <param name="connection">The <see cref="DbConnection" /> being used.</param>
2020
/// <param name="command">The <see cref="DbCommand" /> that was executing when it failed.</param>
21+
/// <param name="logCommandText">The command text that can be logged.</param>
2122
/// <param name="context">The <see cref="DbContext" /> currently being used, to null if not known.</param>
2223
/// <param name="executeMethod">The <see cref="DbCommand" /> method that was used to execute the command.</param>
2324
/// <param name="commandId">A correlation ID that identifies the <see cref="DbCommand" /> instance being used.</param>
@@ -33,6 +34,7 @@ public CommandErrorEventData(
3334
Func<EventDefinitionBase, EventData, string> messageGenerator,
3435
DbConnection connection,
3536
DbCommand command,
37+
string logCommandText,
3638
DbContext? context,
3739
DbCommandMethod executeMethod,
3840
Guid commandId,
@@ -48,6 +50,7 @@ public CommandErrorEventData(
4850
messageGenerator,
4951
connection,
5052
command,
53+
logCommandText,
5154
context,
5255
executeMethod,
5356
commandId,

Diff for: src/EFCore.Relational/Diagnostics/CommandEventData.cs

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class CommandEventData : CommandCorrelatedEventData
1919
/// <param name="messageGenerator">A delegate that generates a log message for this event.</param>
2020
/// <param name="connection">The <see cref="DbConnection" /> being used.</param>
2121
/// <param name="command">The <see cref="DbCommand" />.</param>
22+
/// <param name="logCommandText">The command text that can be logged.</param>
2223
/// <param name="context">The <see cref="DbContext" /> currently being used, to null if not known.</param>
2324
/// <param name="executeMethod">The <see cref="DbCommand" /> method.</param>
2425
/// <param name="commandId">A correlation ID that identifies the <see cref="DbCommand" /> instance being used.</param>
@@ -32,6 +33,7 @@ public CommandEventData(
3233
Func<EventDefinitionBase, EventData, string> messageGenerator,
3334
DbConnection connection,
3435
DbCommand command,
36+
string logCommandText,
3537
DbContext? context,
3638
DbCommandMethod executeMethod,
3739
Guid commandId,
@@ -53,6 +55,7 @@ public CommandEventData(
5355
commandSource)
5456
{
5557
Command = command;
58+
LogCommandText = logCommandText;
5659
LogParameterValues = logParameterValues;
5760
}
5861

@@ -61,6 +64,11 @@ public CommandEventData(
6164
/// </summary>
6265
public virtual DbCommand Command { get; }
6366

67+
/// <summary>
68+
/// The command text that can be logged.
69+
/// </summary>
70+
public virtual string LogCommandText { get; }
71+
6472
/// <summary>
6573
/// Indicates whether or not the application allows logging of parameter values.
6674
/// </summary>

Diff for: src/EFCore.Relational/Diagnostics/CommandExecutedEventData.cs

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class CommandExecutedEventData : CommandEndEventData
1818
/// <param name="messageGenerator">A delegate that generates a log message for this event.</param>
1919
/// <param name="connection">The <see cref="DbConnection" /> being used.</param>
2020
/// <param name="command">The <see cref="DbCommand" /> that was executing when it failed.</param>
21+
/// <param name="logCommandText">The command text that can be logged.</param>
2122
/// <param name="context">The <see cref="DbContext" /> currently being used, to null if not known.</param>
2223
/// <param name="executeMethod">The <see cref="DbCommand" /> method that was used to execute the command.</param>
2324
/// <param name="commandId">A correlation ID that identifies the <see cref="DbCommand" /> instance being used.</param>
@@ -33,6 +34,7 @@ public CommandExecutedEventData(
3334
Func<EventDefinitionBase, EventData, string> messageGenerator,
3435
DbConnection connection,
3536
DbCommand command,
37+
string logCommandText,
3638
DbContext? context,
3739
DbCommandMethod executeMethod,
3840
Guid commandId,
@@ -48,6 +50,7 @@ public CommandExecutedEventData(
4850
messageGenerator,
4951
connection,
5052
command,
53+
logCommandText,
5154
context,
5255
executeMethod,
5356
commandId,

0 commit comments

Comments
 (0)