Skip to content

Commit

Permalink
Added basic Debug logging
Browse files Browse the repository at this point in the history
The most significant changes to the `UsernameGenerator.cs` file involve the addition of the `System.Diagnostics` namespace and the inclusion of debugging lines throughout the code. These changes are aimed at improving the debugging process by providing detailed diagnostic messages at various points in the code.
  • Loading branch information
fazelukario committed Apr 25, 2024
1 parent 3e98b16 commit 765f4f5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions UsernameGenerator/UsernameGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -29,8 +30,12 @@ static UsernameGenerator()

if (resourcesPath != null && Directory.Exists(resourcesPath))
{
Debug.WriteLine("Loading resources from: " + resourcesPath);

LoadResources(resourcesPath);

Debug.WriteLine("Resources loaded");

_fileSystemWatcher = new FileSystemWatcher(resourcesPath, "*.txt")
{
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
Expand All @@ -45,7 +50,11 @@ static UsernameGenerator()
}
else
{
Debug.WriteLine("Loading default resources");

LoadResources();

Debug.WriteLine("Default resources loaded");
}
}

Expand Down Expand Up @@ -169,6 +178,11 @@ private static void LoadResources(string resourcesPath = null)

private static void ReloadResources(object sender, FileSystemEventArgs e)
{
Debug.WriteLine("Reloading resources");
Debug.WriteLine("Resource: " + e.Name);
Debug.WriteLine("Path: " + e.FullPath);
Debug.WriteLine("Event: " + e.ChangeType);

switch (e.Name)
{
case "Adjectives.txt":
Expand All @@ -184,6 +198,8 @@ private static void ReloadResources(object sender, FileSystemEventArgs e)
Animals = Resources.Animals;
break;
}

Debug.WriteLine("Resources reloaded");
}
}
}

0 comments on commit 765f4f5

Please sign in to comment.