-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ log messages for connection, method and query events
- Loading branch information
Showing
26 changed files
with
888 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
SurrealDb.Net.Tests/DependencyInjection/SurrealDbLoggingOptionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using SurrealDb.Net.Extensions.DependencyInjection; | ||
|
||
namespace SurrealDb.Net.Tests.DependencyInjection; | ||
|
||
public class SurrealDbLoggingOptionsTests | ||
{ | ||
[Fact] | ||
public void SensitiveDataLoggingShouldBeDisabledByDefault() | ||
{ | ||
new SurrealDbLoggingOptions().SensitiveDataLoggingEnabled.Should().BeFalse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
SurrealDb.Net.Tests/Extensions/SurrealDbLoggerExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using SurrealDb.Net.Internals.Extensions; | ||
|
||
namespace SurrealDb.Net.Tests.Extensions; | ||
|
||
public class SurrealDbLoggerExtensionsTests | ||
{ | ||
[Theory] | ||
[InlineData(null, false, "?")] | ||
[InlineData(null, true, "null")] | ||
[InlineData(true, false, "?")] | ||
[InlineData(true, true, "'True'")] | ||
[InlineData(34, false, "?")] | ||
[InlineData(34, true, "'34'")] | ||
[InlineData("Hello world", false, "?")] | ||
[InlineData("Hello world", true, "'Hello world'")] | ||
public void ShouldFormatParameterValue( | ||
object value, | ||
bool shouldLogParameterValue, | ||
string expected | ||
) | ||
{ | ||
SurrealDbLoggerExtensions | ||
.FormatParameterValue(value, shouldLogParameterValue) | ||
.Should() | ||
.Be(expected); | ||
} | ||
|
||
[Fact] | ||
public void ShouldFormatRequestParametersWithSensitive() | ||
{ | ||
string result = SurrealDbLoggerExtensions.FormatRequestParameters( | ||
[1, "Hello", "test"], | ||
false | ||
); | ||
result.Should().Be("[?, ?, ?]"); | ||
} | ||
|
||
[Fact] | ||
public void ShouldFormatRequestParametersWithoutSensitive() | ||
{ | ||
string result = SurrealDbLoggerExtensions.FormatRequestParameters( | ||
[1, "Hello", "test"], | ||
true | ||
); | ||
result.Should().Be("['1', 'Hello', 'test']"); | ||
} | ||
|
||
[Fact] | ||
public void ShouldFormatQueryParametersWithSensitive() | ||
{ | ||
string result = SurrealDbLoggerExtensions.FormatQueryParameters( | ||
new Dictionary<string, object?>() | ||
{ | ||
{ "p0", 1 }, | ||
{ "p1", "Hello" }, | ||
{ "p2", "test" }, | ||
}, | ||
false | ||
); | ||
result.Should().Be("$p0=?, $p1=?, $p2=?"); | ||
} | ||
|
||
[Fact] | ||
public void ShouldFormatQueryParametersWithoutSensitive() | ||
{ | ||
string result = SurrealDbLoggerExtensions.FormatQueryParameters( | ||
new Dictionary<string, object?>() | ||
{ | ||
{ "p0", 1 }, | ||
{ "p1", "Hello" }, | ||
{ "p2", "test" }, | ||
}, | ||
true | ||
); | ||
result.Should().Be("$p0='1', $p1='Hello', $p2='test'"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using SurrealDb.Net.Internals.Logging; | ||
|
||
namespace SurrealDb.Net.Tests.Logging; | ||
|
||
public class DbLoggerCategoryTests | ||
{ | ||
[Fact] | ||
public void ConnectionLoggerCategoryShouldHaveTheCorrectName() | ||
{ | ||
DbLoggerCategory.Connection.Name.Should().Be("SurrealDB.Connection"); | ||
} | ||
|
||
[Fact] | ||
public void MethodLoggerCategoryShouldHaveTheCorrectName() | ||
{ | ||
DbLoggerCategory.Method.Name.Should().Be("SurrealDB.Method"); | ||
} | ||
|
||
[Fact] | ||
public void QueryLoggerCategoryShouldHaveTheCorrectName() | ||
{ | ||
DbLoggerCategory.Query.Name.Should().Be("SurrealDB.Query"); | ||
} | ||
} |
Oops, something went wrong.