Skip to content

Commit

Permalink
Added some further debug log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrKnarz committed Oct 1, 2024
1 parent 164ec99 commit 8f31bf8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Generic/MetadataUtilities/Actions/AfterMetadataUpdateAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MetadataUtilities.Enums;
using KNARZhelper;
using MetadataUtilities.Enums;
using MetadataUtilities.Models;
using Playnite.SDK;

Expand All @@ -20,6 +21,14 @@ private AfterMetadataUpdateAction(Settings settings) : base(settings)

public override bool Execute(MyGame game, ActionModifierType actionModifier = ActionModifierType.None, object item = null, bool isBulkAction = true)
{
if (Settings.WriteDebugLog)
{
Log.Debug($"===> Game \"{game.Game.Name}\" =======================================");
Log.Debug($"ExecuteRemoveUnwanted: {game.ExecuteRemoveUnwanted}");
Log.Debug($"ExecuteMergeRules: {game.ExecuteMergeRules}");
Log.Debug($"ExecuteConditionalActions: {game.ExecuteConditionalActions}");
}

if (!base.Execute(game, actionModifier, item, isBulkAction))
{
return false;
Expand Down Expand Up @@ -69,6 +78,13 @@ public override void FollowUp(ActionModifierType actionModifier = ActionModifier

public override bool Prepare(ActionModifierType actionModifier = ActionModifierType.None, object item = null, bool isBulkAction = true)
{
if (Settings.WriteDebugLog)
{
Log.Debug($"===> preparing AfterMetadataUpdate =======================");
Log.Debug($"RemoveUnwantedOnMetadataUpdate: {Settings.RemoveUnwantedOnMetadataUpdate}");
Log.Debug($"MergeMetadataOnMetadataUpdate: {Settings.MergeMetadataOnMetadataUpdate}");
}

if (!base.Prepare(ActionModifierType.IsCombi, item, isBulkAction))
{
return false;
Expand Down
16 changes: 16 additions & 0 deletions Generic/MetadataUtilities/MetadataFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Forms;
using MergeAction = MetadataUtilities.Actions.MergeAction;

namespace MetadataUtilities
{
Expand All @@ -22,6 +23,11 @@ public static void DoForAll(MetadataUtilities plugin, List<MyGame> games, IBaseA
{
plugin.IsUpdating = true;

if (plugin.Settings.Settings.WriteDebugLog)
{
Log.Debug($"===> Started {action.GetType()} for {games.Count} games. =======================");
}

Cursor.Current = Cursors.WaitCursor;
try
{
Expand Down Expand Up @@ -84,6 +90,11 @@ public static void DoForAll(MetadataUtilities plugin, List<MyGame> games, IBaseA
}, globalProgressOptions);
}

if (plugin.Settings.Settings.WriteDebugLog)
{
Log.Debug($"===> Finished {action.GetType()} with {gamesAffected} games affected. =======================");
}

// Shows a dialog with the number of games actually affected.
if (!showDialog)
{
Expand Down Expand Up @@ -355,6 +366,11 @@ public static void UpdateGames<T>(List<T> games)
}
}

if (MergeAction.Instance(null).Settings?.WriteDebugLog ?? false)
{
Log.Debug($"Updating {gamesToUpdate.Count} games:\n{string.Join("\n", gamesToUpdate.Select(g => g.Name))}");
}

if (gamesToUpdate.Count == 0)
{
return;
Expand Down
5 changes: 5 additions & 0 deletions Generic/MetadataUtilities/MetadataUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public MetadataUtilities(IPlayniteAPI api) : base(api)

public void Games_ItemUpdated(object sender, ItemUpdatedEventArgs<Game> args)
{
if (Settings.Settings.WriteDebugLog)
{
Log.Debug($"IsUpdating: {IsUpdating}");
}

if (IsUpdating)
{
return;
Expand Down

0 comments on commit 8f31bf8

Please sign in to comment.