Skip to content

Commit a0ec9ac

Browse files
committed
Prune JSON fields at max
1 parent 74fb5de commit a0ec9ac

29 files changed

+253
-255
lines changed

Src/ConsoleTest/App.config

Lines changed: 0 additions & 49 deletions
This file was deleted.

Src/ConsoleTest/ConsoleTest.csproj

Lines changed: 0 additions & 79 deletions
This file was deleted.

Src/ConsoleTest/Program.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

Src/ConsoleTest/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Src/ConsoleTest/packages.config

Lines changed: 0 additions & 4 deletions
This file was deleted.

Src/StackifyLib/Config.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using StackifyLib.Utils;
@@ -101,6 +101,15 @@ public static void LoadSettings()
101101
{
102102
ApiLog = apiLog.Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase);
103103
}
104+
105+
var loggingJsonMaxFields = Get("Stackify.Logging.JsonMaxFields", "50");
106+
if (string.IsNullOrWhiteSpace(loggingJsonMaxFields) == false)
107+
{
108+
if (int.TryParse(loggingJsonMaxFields, out int maxFields) && maxFields > 0 && maxFields < 100)
109+
{
110+
LoggingJsonMaxFields = maxFields;
111+
}
112+
}
104113
}
105114
catch (Exception ex)
106115
{
@@ -141,6 +150,9 @@ public static void LoadSettings()
141150

142151
public static bool? ApiLog { get; set; }
143152

153+
public static int LoggingJsonMaxFields { get; set; } = 50;
154+
155+
144156
/// <summary>
145157
/// Attempts to fetch a setting value given the key.
146158
/// .NET configuration file will be used first, if the key is not found, environment variable will be used next.
@@ -196,4 +208,4 @@ internal static string Get(string key, string defaultValue = null)
196208
return v;
197209
}
198210
}
199-
}
211+
}

Src/StackifyLib/Internal/Logs/LogClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using Newtonsoft.Json;
22
using StackifyLib.Models;
33
using StackifyLib.Utils;
44
using System;
@@ -77,7 +77,7 @@ public bool IsAuthorized()
7777
{
7878
EnsureHttpClient();
7979
return _HttpClient.IsAuthorized();
80-
80+
8181
}
8282

8383
public bool CanUpload()
@@ -165,7 +165,7 @@ public void QueueMessage(LogMsg msg)
165165
{
166166
msg.SetLogMsgID(msg.id, isError, msg.Level, null, null);
167167
}
168-
168+
169169

170170
//We need to do everything up to this point for sasquatch. Even if we aren't uploading the log.
171171
if (this.CanQueue())
@@ -199,7 +199,7 @@ public void QueueMessage(LogMsg msg)
199199
var defaults = CreateDefaultMsgGroup();
200200

201201
//default app, env, and server name if not set to whatever the current one is
202-
//do not default the other fields as they not match what is being set.
202+
//do not default the other fields as they not match what is being set.
203203
//i.e. the default appnameid is not the correct id for a new custom app name being used.
204204
var d = message.AppDetails;
205205
var group = new LogMsgGroup()
@@ -217,7 +217,7 @@ public void QueueMessage(LogMsg msg)
217217
ServerName = d.ServerName ?? defaults.ServerName,
218218
Msgs = new List<LogMsg>()
219219
};
220-
220+
221221
groups[groupKey] = group;
222222
}
223223
}
@@ -317,7 +317,7 @@ internal HttpClient.StackifyWebResponse SendLogsByGroups(LogMsg[] messages)
317317

318318
string jsonData = JsonConvert.SerializeObject(groups, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
319319

320-
320+
321321
string urlToUse = (_HttpClient.BaseAPIUrl) + "Log/SaveMultipleGroups";
322322

323323

0 commit comments

Comments
 (0)