Skip to content

Commit

Permalink
Change debug traces location to the well-known location of .sponsorlink
Browse files Browse the repository at this point in the history
Makes it easier to find alongside the rest. Tracing won't happen by default unless you set SPONSORLINK_TRACE=1 or have a debug build
  • Loading branch information
kzu committed Jun 28, 2024
1 parent 068140b commit 1019e2a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/SponsorLink/SponsorLink/Tracing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ public static void Trace([CallerMemberName] string? message = null, [CallerFileP
.AppendLine($" -> {filePath}({lineNumber})")
.ToString();

var dir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.Create);
var dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".sponsorlink");
Directory.CreateDirectory(dir);

var tries = 0;
// Best-effort only
while (tries < 10)
{
try
{
File.AppendAllText(Path.Combine(dir, "SponsorLink.log"), line);
File.AppendAllText(Path.Combine(dir, "trace.log"), line);
Debugger.Log(0, "SponsorLink", line);
return;
}
Expand Down

0 comments on commit 1019e2a

Please sign in to comment.