Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tag support for including tags in the exceptionless feed #18

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Exceptionless;
using Exceptionless.Logging;
using Serilog.Core;
Expand Down Expand Up @@ -36,6 +37,24 @@ internal static string GetSource(this LogEvent log) {
return null;
}

internal static string[] GetTags(this LogEvent log)
niemyjski marked this conversation as resolved.
Show resolved Hide resolved
{
if (log.Properties.TryGetValue("Tags", out LogEventPropertyValue value))
{
var propertyCollection = value.FlattenProperties() as List<object>;
if (propertyCollection == null) return Array.Empty<string>();

List<string> tags = new List<string>();
foreach (var item in propertyCollection)
{
tags.Add(item.ToString());
}

return tags.ToArray();
}
return Array.Empty<string>();
}

internal static LogLevel GetLevel(this LogEventLevel log)
{
switch (log)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void Emit(LogEvent logEvent) {
if (logEvent.Level.GetLevel() < minLogLevel)
return;

var builder = _client.CreateFromLogEvent(logEvent).AddTags(_defaultTags);
var builder = _client.CreateFromLogEvent(logEvent).AddTags(_defaultTags).AddTags(logEvent.GetTags());

if (_includeProperties) {
foreach (var prop in logEvent.Properties)
Expand Down
Loading