Skip to content

Commit c68cc0c

Browse files
committed
Moved getTags extension to LogEventPropertyValue and moved to the existing iteration through properties
1 parent b303dd5 commit c68cc0c

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/Serilog.Sinks.Exceptionless/Sinks/Exceptionless/ExceptionlessClientExtensions.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,18 @@ internal static string GetSource(this LogEvent log) {
3737
return null;
3838
}
3939

40-
internal static string[] GetTags(this LogEvent log)
40+
internal static string[] GetTags(this LogEventPropertyValue value)
4141
{
42-
if (log.Properties.TryGetValue("Tags", out LogEventPropertyValue value))
43-
{
44-
var propertyCollection = value.FlattenProperties() as List<object>;
45-
if (propertyCollection == null) return Array.Empty<string>();
46-
47-
List<string> tags = new List<string>();
48-
foreach (var item in propertyCollection)
49-
{
50-
tags.Add(item.ToString());
51-
}
42+
var propertyCollection = value.FlattenProperties() as List<object>;
43+
if (propertyCollection == null) return Array.Empty<string>();
5244

53-
return tags.ToArray();
45+
List<string> tags = new List<string>();
46+
foreach (var item in propertyCollection)
47+
{
48+
tags.Add(item.ToString());
5449
}
55-
return Array.Empty<string>();
50+
51+
return tags.ToArray();
5652
}
5753

5854
internal static LogLevel GetLevel(this LogEventLevel log)

src/Serilog.Sinks.Exceptionless/Sinks/Exceptionless/ExceptionlessSink.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void Emit(LogEvent logEvent) {
108108
if (logEvent.Level.GetLevel() < minLogLevel)
109109
return;
110110

111-
var builder = _client.CreateFromLogEvent(logEvent).AddTags(_defaultTags).AddTags(logEvent.GetTags());
111+
var builder = _client.CreateFromLogEvent(logEvent).AddTags(_defaultTags);
112112

113113
if (_includeProperties) {
114114
foreach (var prop in logEvent.Properties)
@@ -139,6 +139,9 @@ public void Emit(LogEvent logEvent) {
139139
if (!String.IsNullOrWhiteSpace(emailAddress) || !String.IsNullOrWhiteSpace(description))
140140
builder.SetUserDescription(emailAddress, description);
141141
break;
142+
case "Tags":
143+
builder.AddTags(prop.Value.GetTags());
144+
break;
142145
default:
143146
builder.SetProperty(prop.Key, prop.Value.FlattenProperties());
144147
break;

0 commit comments

Comments
 (0)