Skip to content

Commit def3345

Browse files
committed
Fix some more logging
1 parent e88ca4f commit def3345

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

BepInEx.Preloader/Entrypoint.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private static void LoadCriticalAssemblies()
3131
{
3232
foreach (string criticalAssembly in CriticalAssemblies)
3333
{
34-
Console.Error.WriteLine($"debug BepInEx Loading critical assembly {criticalAssembly}");
34+
Logging.Stderr.WriteLine($"debug BepInEx Loading critical assembly {criticalAssembly}");
3535
try
3636
{
3737
Assembly.LoadFile(Path.Combine(Paths.BepInExAssemblyDirectory, criticalAssembly));
@@ -40,7 +40,7 @@ private static void LoadCriticalAssemblies()
4040
{
4141
// Suppress error for now
4242
// TODO: Should we crash here if load fails? Can't use logging at this point
43-
Console.Error.WriteLine($"err BepInEx Failed to load critical assembly: {ex}");
43+
Logging.Stderr.WriteLine($"err BepInEx Failed to load critical assembly: {ex}");
4444
}
4545
}
4646
}
@@ -73,7 +73,7 @@ private static void PreloaderMain()
7373

7474
private static Assembly LocalResolve(object sender, ResolveEventArgs args)
7575
{
76-
Console.Error.WriteLine($"debug BepInEx Attempting local resolution of {args.Name}");
76+
Logging.Stderr.WriteLine($"debug BepInEx Attempting local resolution of {args.Name}");
7777

7878
if (!Utility.TryParseAssemblyName(args.Name, out var assemblyName))
7979
return null;
@@ -116,7 +116,7 @@ internal static class Entrypoint
116116
/// </summary>
117117
public static void Start()
118118
{
119-
Console.Error.WriteLine("info BepInEx Starting");
119+
Logging.Stderr.WriteLine("info BepInEx Starting");
120120

121121
try
122122
{
@@ -137,7 +137,7 @@ public static void Start()
137137
}
138138
catch (Exception ex)
139139
{
140-
Console.Error.WriteLine($"fatal BepInEx {ex}");
140+
Logging.Stderr.WriteLine($"fatal BepInEx {ex}");
141141
}
142142
finally
143143
{

BepInEx.Preloader/Logging.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
namespace BepInEx.Preloader {
4+
internal static class Logging {
5+
private static System.IO.TextWriter _Stderr;
6+
7+
public static System.IO.TextWriter Stderr
8+
{
9+
get {
10+
if (_Stderr == null) {
11+
_Stderr = Console.Error;
12+
}
13+
return _Stderr;
14+
}
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)