Skip to content

Commit

Permalink
dev: add DeviceLang enricher
Browse files Browse the repository at this point in the history
  • Loading branch information
markjackmilian committed Dec 21, 2022
1 parent 8a13a80 commit a3541c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Globalization;
using Serilog.Core;
using Serilog.Events;

namespace nightly.serilog.xamarin.Enrichers.DeviceInfo
{
public class DeviceLangEnricher : ILogEventEnricher
{
private LogEventProperty _cachedProperty;

public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
this._cachedProperty ??= propertyFactory.CreateProperty("DeviceLang", CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
logEvent.AddPropertyIfAbsent(this._cachedProperty);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static LoggerConfiguration WithDeviceInfos(this LoggerEnrichmentConfigura
enrichment.With<DeviceNameEnricher>();
enrichment.With<DeviceOsVersionEnricher>();
enrichment.With<DevicePlatformEnricher>();
enrichment.With<DeviceLangEnricher>();
return enrichment.With<DeviceTypeEnricher>();
}

Expand Down

0 comments on commit a3541c4

Please sign in to comment.