Skip to content

Commit 10afe06

Browse files
authored
Merge branch 'dev' into serilog-4x
2 parents 51770bd + 7fc50b0 commit 10afe06

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLogger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state
103103
{
104104
messageTemplate = value;
105105
}
106-
else if (property.Key.StartsWith("@", StringComparison.Ordinal))
106+
else if (property.Key.StartsWith('@'))
107107
{
108108
if (_logger.BindProperty(GetKeyWithoutFirstSymbol(DestructureDictionary, property.Key), property.Value, true, out var destructured))
109109
properties[destructured.Name] = destructured.Value;
110110
}
111-
else if (property.Key.StartsWith("$", StringComparison.Ordinal))
111+
else if (property.Key.StartsWith('$'))
112112
{
113113
if (_logger.BindProperty(GetKeyWithoutFirstSymbol(StringifyDictionary, property.Key), property.Value?.ToString(), true, out var stringified))
114114
properties[stringified.Name] = stringified.Value;

src/Serilog.Extensions.Logging/Extensions/Logging/SerilogLoggerScope.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ static void AddProperty(LogEvent logEvent, ILogEventPropertyFactory propertyFact
106106
{
107107
var destructureObject = false;
108108

109-
if (key.StartsWith("@", StringComparison.Ordinal))
109+
if (key.StartsWith('@'))
110110
{
111111
key = SerilogLogger.GetKeyWithoutFirstSymbol(SerilogLogger.DestructureDictionary, key);
112112
destructureObject = true;
113113
}
114-
else if (key.StartsWith("$", StringComparison.Ordinal))
114+
else if (key.StartsWith('$'))
115115
{
116116
key = SerilogLogger.GetKeyWithoutFirstSymbol(SerilogLogger.StringifyDictionary, key);
117117
value = value?.ToString();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Runtime.CompilerServices;
2+
3+
namespace Serilog.Extensions;
4+
5+
#if !NET6_0_OR_GREATER && !NETSTANDARD2_1_OR_GREATER
6+
static class StringExtensions
7+
{
8+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9+
public static bool StartsWith(this string str, char value)
10+
{
11+
return str.Length > 0 && str[0] == value;
12+
}
13+
}
14+
#endif

0 commit comments

Comments
 (0)