Skip to content

Commit 5b94c6d

Browse files
authored
Merge pull request #128 from github/feature/less_log_noise
0 script diffs are logged as debug instead of info
2 parents fea30c6 + 8a925dc commit 5b94c6d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

KustoSchemaTools/Changes/DatabaseChanges.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ private static List<IChange> GenerateScriptCompareChanges<T>(Database oldState,
194194
if (existing.ContainsKey(item.Key))
195195
{
196196
var change = new ScriptCompareChange(item.Key, existing[item.Key], item.Value);
197-
log.LogInformation($"{item.Key} already exists, created {change.Scripts.Count} script to apply the diffs");
197+
LogChangeResult(log, item.Key, change.Scripts.Count, alreadyExists: true);
198198
tmp.Add(change);
199199
}
200200
else
201201
{
202202
var change = new ScriptCompareChange(item.Key, null, item.Value);
203-
log.LogInformation($"{item.Key} doesn't exist, created {change.Scripts.Count} scripts to create it.");
203+
LogChangeResult(log, item.Key, change.Scripts.Count, alreadyExists: false);
204204
tmp.Add(change);
205205
}
206206
}
@@ -340,6 +340,17 @@ private static List<IChange> GenerateFollowerCachingChanges(FollowerDatabase old
340340

341341
return result;
342342
}
343+
344+
private static void LogChangeResult(ILogger log, string entityKey, int scriptCount, bool alreadyExists)
345+
{
346+
var level = scriptCount > 0 ? LogLevel.Information : LogLevel.Debug;
347+
var scriptsLabel = scriptCount == 1 ? "script" : "scripts";
348+
var message = alreadyExists
349+
? $"{entityKey} already exists, created {scriptCount} {scriptsLabel} to apply the diffs."
350+
: $"{entityKey} doesn't exist, created {scriptCount} {scriptsLabel} to create it.";
351+
352+
log.Log(level, message);
353+
}
343354
}
344355

345356
}

0 commit comments

Comments
 (0)