Skip to content

Commit d98fe20

Browse files
committed
Being less spammy on some spam logs
1 parent 7cd9410 commit d98fe20

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

Source/ModuleManager/MMPatchLoader.cs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,10 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
620620

621621
#region Values
622622

623-
string vals = "modding values";
623+
List<string> logModdingValues = new List<string>();
624624
foreach (ConfigNode.Value modVal in mod.values)
625625
{
626-
vals += "\n " + modVal.name + "= " + modVal.value;
626+
string logModdingValue = modVal.name + " = " + modVal.value;
627627

628628
Command cmd = CommandParser.Parse(modVal.name, out string valName);
629629

@@ -808,7 +808,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
808808
if (value != null)
809809
{
810810
if (origVal.value != value)
811-
vals += ": " + origVal.value + " -> " + value;
811+
logModdingValue += " ( was " + origVal.value + ")";
812812

813813
if (cmd != Command.Copy)
814814
origVal.value = value;
@@ -904,8 +904,10 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
904904
}
905905
break;
906906
}
907+
logModdingValues.Add(logModdingValue);
907908
}
908-
log.Trace(vals);
909+
if (0 != logModdingValues.Count)
910+
log.Trace("\tmodding values: {0}", string.Join(" ; ", logModdingValues.ToArray()));
909911

910912
#endregion Values
911913

@@ -983,7 +985,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
983985
string tag = "";
984986
string nodeType, nodeName;
985987
int index = 0;
986-
List<string> logspam_msg = new List<string>();
988+
List<string> logspam_msg = new List<string>(); logspam_msg.Add("");
987989
List<ConfigNode> subNodes = new List<ConfigNode>();
988990

989991
// three ways to specify:
@@ -1034,7 +1036,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
10341036
}
10351037
}
10361038
else
1037-
logspam_msg.Add(" cannot wildcard a % node: " + subMod.name);
1039+
logspam_msg.Add("Cannot wildcard a % node: " + subMod.name);
10381040
}
10391041
else
10401042
{
@@ -1049,15 +1051,15 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
10491051
// if the original exists modify it
10501052
if (subNodes.Count > 0)
10511053
{
1052-
logspam_msg.Add(" Applying subnode " + subMod.name);
1054+
logspam_msg.Add("Applying subnode " + subMod.name);
10531055
ConfigNode newSubNode = ModifyNode(log, nodeStack.Push(subNodes[0]), subMod, context);
10541056
subNodes[0].ShallowCopyFrom(newSubNode);
10551057
subNodes[0].name = newSubNode.name;
10561058
}
10571059
else
10581060
{
10591061
// if not add the mod node without the % in its name
1060-
logspam_msg.Add(" Adding subnode " + subMod.name);
1062+
logspam_msg.Add("Adding subnode " + subMod.name);
10611063

10621064
ConfigNode copy = new ConfigNode(nodeType);
10631065

@@ -1072,7 +1074,7 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
10721074
{
10731075
if (subNodes.Count == 0)
10741076
{
1075-
logspam_msg.Add(" Adding subnode " + subMod.name);
1077+
logspam_msg.Add("Adding subnode " + subMod.name);
10761078

10771079
ConfigNode copy = new ConfigNode(nodeType);
10781080

@@ -1087,11 +1089,11 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
10871089
{
10881090
// find each original subnode to modify, modify it and add the modified.
10891091
if (subNodes.Count == 0) // no nodes to modify!
1090-
logspam_msg.Add(" Could not find node(s) to modify: " + subMod.name);
1092+
logspam_msg.Add("Could not find node(s) to modify: " + subMod.name);
10911093

10921094
foreach (ConfigNode subNode in subNodes)
10931095
{
1094-
logspam_msg.Add(" Applying subnode " + subMod.name);
1096+
logspam_msg.Add("Applying subnode " + subMod.name);
10951097
ConfigNode newSubNode;
10961098
switch (command)
10971099
{
@@ -1118,7 +1120,8 @@ public static ConfigNode ModifyNode(IBasicLogger log, NodeStack original, Config
11181120
}
11191121
}
11201122
}
1121-
log.Trace(String.Join("\n", logspam_msg.ToArray())); //FIXME: This is wasting a lot of CPU when Trace is deactivated!
1123+
if (logspam_msg.Count > 1) // Remember we added an empty line on initialization
1124+
log.Trace(String.Join("\n\t", logspam_msg.ToArray()));
11221125
}
11231126
}
11241127

@@ -1412,6 +1415,7 @@ private static ConfigNode.Value RecurseVariableSearch(IBasicLogger log, string p
14121415

14131416
private static string ProcessVariableSearch(IBasicLogger log, string value, NodeStack nodeStack, PatchContext context)
14141417
{
1418+
string r = value;
14151419
// value = #xxxx$yyyyy$zzzzz$aaaa$bbbb
14161420
// There is 2 or more '$'
14171421
if (value.Length > 0 && value[0] == '#' && value.IndexOf('$') != -1 && value.IndexOf('$') != value.LastIndexOf('$'))
@@ -1433,10 +1437,10 @@ private static string ProcessVariableSearch(IBasicLogger log, string value, Node
14331437
builder.Append(result.value);
14341438
builder.Append(split[i + 1]);
14351439
}
1436-
value = builder.ToString();
1437-
log.Info("variable search output : =\"{0}\"", value);
1440+
r = builder.ToString();
1441+
log.Detail("variable search output : {0} = \"{1}\"", value, r);
14381442
}
1439-
return value;
1443+
return r;
14401444
}
14411445

14421446
#endregion Applying Patches
@@ -1513,10 +1517,10 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
15131517
}
15141518
if (last != null)
15151519
{
1516-
log.Trace("CheckConstraints: {0} {1}", constraints, (not ^ any));
1520+
log.Trace("\tCheckConstraints: {0} {1}", constraints, (not ^ any));
15171521
return not ^ any;
15181522
}
1519-
log.Trace("CheckConstraints: {0} {1}", constraints, (not ^ false));
1523+
log.Trace("\tCheckConstraints: {0} {1}", constraints, (not ^ false));
15201524
return not ^ false;
15211525

15221526
case '#':
@@ -1525,10 +1529,10 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
15251529
if (node.HasValue(type) && WildcardMatchValues(node, type, name))
15261530
{
15271531
bool ret2 = CheckConstraints(log, node, remainingConstraints);
1528-
log.Trace("CheckConstraints: {0} {1}", constraints, ret2);
1532+
log.Trace("\tCheckConstraints: {0} {1}", constraints, ret2);
15291533
return ret2;
15301534
}
1531-
log.Trace("CheckConstraints: {0} false", constraints);
1535+
log.Trace("\tCheckConstraints: {0} false", constraints);
15321536
return false;
15331537

15341538
case '~':
@@ -1537,20 +1541,20 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
15371541
// or: ~breakingForce[100] will be true if it's present but not 100, too.
15381542
if (name == "" && node.HasValue(type))
15391543
{
1540-
log.Trace("CheckConstraints: {0} false", constraints);
1544+
log.Trace("\tCheckConstraints: {0} false", constraints);
15411545
return false;
15421546
}
15431547
if (name != "" && WildcardMatchValues(node, type, name))
15441548
{
1545-
log.Trace("CheckConstraints: {0} false", constraints);
1549+
log.Trace("\tCheckConstraints: {0} false", constraints);
15461550
return false;
15471551
}
15481552
bool ret = CheckConstraints(log, node, remainingConstraints);
1549-
log.Trace("CheckConstraints: {0} {1}", constraints, ret);
1553+
log.Trace("\tCheckConstraints: {0} {1}", constraints, ret);
15501554
return ret;
15511555

15521556
default:
1553-
log.Trace("CheckConstraints: {0} false", constraints);
1557+
log.Trace("\tCheckConstraints: {0} false", constraints);
15541558
return false;
15551559
}
15561560
}
@@ -1560,7 +1564,7 @@ public static bool CheckConstraints(IBasicLogger log, ConfigNode node, string co
15601564
{
15611565
ret3 = ret3 && CheckConstraints(log, node, constraint);
15621566
}
1563-
log.Trace("CheckConstraints: {0} {1}", constraints, ret3);
1567+
log.Trace("\tCheckConstraints: {0} {1}", constraints, ret3);
15641568
return ret3;
15651569
}
15661570

Source/ModuleManager/Patches/EditPatch.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public void Apply(LinkedList<IProtoUrlConfig> databaseConfigs, IPatchProgress pr
6363
{
6464
progress.ApplyingUpdate(protoConfig, UrlConfig);
6565
listNode.Value = protoConfig = new ProtoUrlConfig(protoConfig.UrlFile, MMPatchLoader.ModifyNode(this.log, new NodeStack(protoConfig.Node), UrlConfig.config, context));
66+
if (loop) logger.Trace("Loop!");
6667
} while (loop && NodeMatcher.IsMatch(protoConfig.Node));
6768

6869
if (loop) protoConfig.Node.RemoveNodes("MM_PATCH_LOOP");

0 commit comments

Comments
 (0)