Skip to content

Commit

Permalink
fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Dec 12, 2024
1 parent ef47856 commit e309ec1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ var log = new LoggerConfiguration()
Apply the `LogWithName` attribute:

<!-- snippet: LogWithName -->
<a id='snippet-logwithname'></a>
<a id='snippet-LogWithName'></a>
```cs
public class PersonalData
{
[LogWithName("FullName")]
public string? Name { get; set; }
}
```
<sup><a href='/src/Destructurama.Attributed.Tests/LogWithNameAttributeTests.cs#L64-L70' title='Snippet source file'>snippet source</a> | <a href='#snippet-logwithname' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/LogWithNameAttributeTests.cs#L64-L70' title='Snippet source file'>snippet source</a> | <a href='#snippet-LogWithName' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## 2. Ignoring a property

Apply the `NotLogged` attribute:

<!-- snippet: LoginCommand -->
<a id='snippet-logincommand'></a>
<a id='snippet-LoginCommand'></a>
```cs
public class LoginCommand
{
Expand All @@ -73,18 +73,18 @@ public class LoginCommand
public string? Password { get; set; }
}
```
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L29-L37' title='Snippet source file'>snippet source</a> | <a href='#snippet-logincommand' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L29-L37' title='Snippet source file'>snippet source</a> | <a href='#snippet-LoginCommand' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

When the object is passed using `{@...}` syntax the attributes will be consulted.

<!-- snippet: LogCommand -->
<a id='snippet-logcommand'></a>
<a id='snippet-LogCommand'></a>
```cs
var command = new LoginCommand { Username = "logged", Password = "not logged" };
_log.Information("Logging in {@Command}", command);
```
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L44-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-logcommand' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L44-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-LogCommand' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## 3. Ignoring a property if it has default value
Expand Down Expand Up @@ -159,7 +159,7 @@ Note that masking also works for properties of type `IEnumerable<string>` or der
### Examples

<!-- snippet: CustomizedMaskedLogs -->
<a id='snippet-customizedmaskedlogs'></a>
<a id='snippet-CustomizedMaskedLogs'></a>
```cs
public class CustomizedMaskedLogs
{
Expand Down Expand Up @@ -188,25 +188,25 @@ public class CustomizedMaskedLogs
public string? DefaultMaskedNotPreservedOnEmptyString { get; set; }

/// <summary>
/// 123456789 results in "#"
/// 123456789 results in "#"
/// </summary>
[LogMasked(Text = "_REMOVED_")]
public string? CustomMasked { get; set; }

/// <summary>
/// 123456789 results in "#"
/// 123456789 results in "#"
/// </summary>
[LogMasked(Text = "")]
public string? CustomMaskedWithEmptyString { get; set; }

/// <summary>
/// 123456789 results in "#########"
/// 123456789 results in "#########"
/// </summary>
[LogMasked(Text = "#", PreserveLength = true)]
public string? CustomMaskedPreservedLength { get; set; }

/// <summary>
/// 123456789 results in "123******"
/// 123456789 results in "123******"
/// </summary>
[LogMasked(ShowFirst = 3)]
public string? ShowFirstThreeThenDefaultMasked { get; set; }
Expand All @@ -230,25 +230,25 @@ public class CustomizedMaskedLogs
public string? ShowLastThreeThenDefaultMaskedPreservedLength { get; set; }

/// <summary>
/// 123456789 results in "123REMOVED"
/// 123456789 results in "123REMOVED"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3)]
public string? ShowFirstThreeThenCustomMask { get; set; }

/// <summary>
/// 123456789 results in "123_REMOVED_"
/// 123456789 results in "123_REMOVED_"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3, PreserveLength = true)]
public string? ShowFirstThreeThenCustomMaskPreservedLengthIgnored { get; set; }

/// <summary>
/// 123456789 results in "_REMOVED_789"
/// 123456789 results in "_REMOVED_789"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowLast = 3)]
public string? ShowLastThreeThenCustomMask { get; set; }

/// <summary>
/// 123456789 results in "_REMOVED_789"
/// 123456789 results in "_REMOVED_789"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowLast = 3, PreserveLength = true)]
public string? ShowLastThreeThenCustomMaskPreservedLengthIgnored { get; set; }
Expand All @@ -272,19 +272,19 @@ public class CustomizedMaskedLogs
public string? ShowFirstAndLastThreeAndDefaultMaskInTheMiddlePreservedLength { get; set; }

/// <summary>
/// 123456789 results in "123_REMOVED_789"
/// 123456789 results in "123_REMOVED_789"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3, ShowLast = 3)]
public string? ShowFirstAndLastThreeAndCustomMaskInTheMiddle { get; set; }

/// <summary>
/// 123456789 results in "123_REMOVED_789". PreserveLength is ignored"
/// 123456789 results in "123_REMOVED_789". PreserveLength is ignored"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3, ShowLast = 3, PreserveLength = true)]
public string? ShowFirstAndLastThreeAndCustomMaskInTheMiddlePreservedLengthIgnored { get; set; }
}
```
<sup><a href='/src/Destructurama.Attributed.Tests/MaskedAttributeTests.cs#L8-L133' title='Snippet source file'>snippet source</a> | <a href='#snippet-customizedmaskedlogs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/MaskedAttributeTests.cs#L8-L133' title='Snippet source file'>snippet source</a> | <a href='#snippet-CustomizedMaskedLogs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## 7. Masking a string property with regular expressions
Expand Down Expand Up @@ -318,7 +318,7 @@ __Available properties__:
### Examples

<!-- snippet: WithRegex -->
<a id='snippet-withregex'></a>
<a id='snippet-WithRegex'></a>
```cs
public class WithRegex
{
Expand All @@ -337,7 +337,7 @@ public class WithRegex
public string? RegexReplaceSecond { get; set; }
}
```
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L6-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-withregex' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Destructurama.Attributed.Tests/Snippets.cs#L6-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-WithRegex' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

# Benchmarks
Expand Down
20 changes: 10 additions & 10 deletions src/Destructurama.Attributed.Tests/MaskedAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ public class CustomizedMaskedLogs
public string? DefaultMaskedNotPreservedOnEmptyString { get; set; }

/// <summary>
/// 123456789 results in "#"
/// 123456789 results in "#"
/// </summary>
[LogMasked(Text = "_REMOVED_")]
public string? CustomMasked { get; set; }

/// <summary>
/// 123456789 results in "#"
/// 123456789 results in "#"
/// </summary>
[LogMasked(Text = "")]
public string? CustomMaskedWithEmptyString { get; set; }

/// <summary>
/// 123456789 results in "#########"
/// 123456789 results in "#########"
/// </summary>
[LogMasked(Text = "#", PreserveLength = true)]
public string? CustomMaskedPreservedLength { get; set; }

/// <summary>
/// 123456789 results in "123******"
/// 123456789 results in "123******"
/// </summary>
[LogMasked(ShowFirst = 3)]
public string? ShowFirstThreeThenDefaultMasked { get; set; }
Expand All @@ -76,25 +76,25 @@ public class CustomizedMaskedLogs
public string? ShowLastThreeThenDefaultMaskedPreservedLength { get; set; }

/// <summary>
/// 123456789 results in "123REMOVED"
/// 123456789 results in "123REMOVED"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3)]
public string? ShowFirstThreeThenCustomMask { get; set; }

/// <summary>
/// 123456789 results in "123_REMOVED_"
/// 123456789 results in "123_REMOVED_"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3, PreserveLength = true)]
public string? ShowFirstThreeThenCustomMaskPreservedLengthIgnored { get; set; }

/// <summary>
/// 123456789 results in "_REMOVED_789"
/// 123456789 results in "_REMOVED_789"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowLast = 3)]
public string? ShowLastThreeThenCustomMask { get; set; }

/// <summary>
/// 123456789 results in "_REMOVED_789"
/// 123456789 results in "_REMOVED_789"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowLast = 3, PreserveLength = true)]
public string? ShowLastThreeThenCustomMaskPreservedLengthIgnored { get; set; }
Expand All @@ -118,13 +118,13 @@ public class CustomizedMaskedLogs
public string? ShowFirstAndLastThreeAndDefaultMaskInTheMiddlePreservedLength { get; set; }

/// <summary>
/// 123456789 results in "123_REMOVED_789"
/// 123456789 results in "123_REMOVED_789"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3, ShowLast = 3)]
public string? ShowFirstAndLastThreeAndCustomMaskInTheMiddle { get; set; }

/// <summary>
/// 123456789 results in "123_REMOVED_789". PreserveLength is ignored"
/// 123456789 results in "123_REMOVED_789". PreserveLength is ignored"
/// </summary>
[LogMasked(Text = "_REMOVED_", ShowFirst = 3, ShowLast = 3, PreserveLength = true)]
public string? ShowFirstAndLastThreeAndCustomMaskInTheMiddlePreservedLengthIgnored { get; set; }
Expand Down

0 comments on commit e309ec1

Please sign in to comment.