Skip to content

Commit

Permalink
General cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed May 2, 2023
1 parent 580eea7 commit 6f33256
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
14 changes: 4 additions & 10 deletions src/Exceptionless/Extensions/DataDictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle
: client.Configuration.DataExclusions.ToArray();

string name = !String.IsNullOrWhiteSpace(info.Name) ? info.Name.Trim() : null;
Type dataType = info.Data.GetType();
var dataType = info.Data.GetType();
if (String.IsNullOrEmpty(name)) {
name = dataType.Name;
int index = 1;
Expand All @@ -115,10 +115,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle
}

if (dataType == typeof(bool) || dataType == typeof(string) || dataType.IsNumeric()) {
if (data.Data.ContainsKey(name))
data.Data[name] = info.Data;
else
data.Data.Add(name, info.Data);
data.Data[name] = info.Data;

return;
}
Expand All @@ -129,7 +126,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle
json = info.Data.ToString();
} else {
var serializer = client.Configuration.Resolver.GetJsonSerializer();
json = serializer.Serialize(info.Data, exclusions, info.MaxDepthToSerialize.HasValue ? info.MaxDepthToSerialize.Value : 5, info.IgnoreSerializationErrors);
json = serializer.Serialize(info.Data, exclusions, info.MaxDepthToSerialize.GetValueOrDefault(5), info.IgnoreSerializationErrors);
}
} catch (Exception ex) {
json = ex.ToString();
Expand All @@ -138,10 +135,7 @@ public static void AddObject(this IData data, ExtendedDataInfo info, Exceptionle
if (String.IsNullOrEmpty(json))
return;

if (data.Data.ContainsKey(name))
data.Data[name] = json;
else
data.Data.Add(name, json);
data.Data[name] = json;
}
}
}
6 changes: 3 additions & 3 deletions src/Exceptionless/Serializer/ExceptionlessContractResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public ExceptionlessContractResolver(Func<JsonProperty, object, bool> includePro
}

protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
var property = base.CreateProperty(member, memberSerialization);
if (_includeProperty == null)
return property;

Predicate<object> shouldSerialize = property.ShouldSerialize;
var shouldSerialize = property.ShouldSerialize;
property.ShouldSerialize = obj => _includeProperty(property, obj) && (shouldSerialize == null || shouldSerialize(obj));
return property;
}

protected override JsonDictionaryContract CreateDictionaryContract(Type objectType) {
JsonDictionaryContract contract = base.CreateDictionaryContract(objectType);
var contract = base.CreateDictionaryContract(objectType);
contract.DictionaryKeyResolver = propertyName => propertyName;
return contract;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ protected override void Write(LogEventInfo logEvent) {
if (!_client.Configuration.IsValid)
return;

LogLevel minLogLevel = LogLevel.FromOrdinal(_client.Configuration.Settings.GetMinLogLevel(logEvent.LoggerName).Ordinal);
var minLogLevel = LogLevel.FromOrdinal(_client.Configuration.Settings.GetMinLogLevel(logEvent.LoggerName).Ordinal);
if (logEvent.Level < minLogLevel)
return;

var formattedMessage = RenderLogEvent(Layout, logEvent);
string formattedMessage = RenderLogEvent(Layout, logEvent);
var builder = _client.CreateFromLogEvent(logEvent, formattedMessage);

var userIdentity = RenderLogEvent(UserIdentity, logEvent);
var userIdentityName = RenderLogEvent(UserIdentityName, logEvent);
string userIdentity = RenderLogEvent(UserIdentity, logEvent);
string userIdentityName = RenderLogEvent(UserIdentityName, logEvent);
builder.Target.SetUserIdentity(userIdentity, userIdentityName);

foreach (var field in Fields) {
var renderedField = RenderLogEvent(field.Layout, logEvent);
string renderedField = RenderLogEvent(field.Layout, logEvent);
if (!String.IsNullOrWhiteSpace(renderedField))
builder.AddObject(renderedField, field.Name);
}
Expand Down

0 comments on commit 6f33256

Please sign in to comment.