|
@@ -7,7 +7,9 @@ namespace BepInEx.Logger
|
|
{
|
|
{
|
|
public class PreloaderLogWriter : BaseLogger
|
|
public class PreloaderLogWriter : BaseLogger
|
|
{
|
|
{
|
|
- public StringBuilder StringBuilder = new StringBuilder();
|
|
|
|
|
|
+ public StringBuilder StringBuilder { get; protected set; } = new StringBuilder();
|
|
|
|
+
|
|
|
|
+ public bool IsRedirectingConsole { get; protected set; }
|
|
|
|
|
|
protected TextWriter stdout;
|
|
protected TextWriter stdout;
|
|
protected LoggerTraceListener traceListener;
|
|
protected LoggerTraceListener traceListener;
|
|
@@ -24,9 +26,13 @@ namespace BepInEx.Logger
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public PreloaderLogWriter()
|
|
|
|
|
|
+ public PreloaderLogWriter(bool redirectConsole)
|
|
{
|
|
{
|
|
- stdout = Console.Out;
|
|
|
|
|
|
+ IsRedirectingConsole = redirectConsole;
|
|
|
|
+
|
|
|
|
+ if (IsRedirectingConsole)
|
|
|
|
+ stdout = Console.Out;
|
|
|
|
+
|
|
traceListener = new LoggerTraceListener(this);
|
|
traceListener = new LoggerTraceListener(this);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -35,7 +41,9 @@ namespace BepInEx.Logger
|
|
if (Enabled)
|
|
if (Enabled)
|
|
return;
|
|
return;
|
|
|
|
|
|
- Console.SetOut(this);
|
|
|
|
|
|
+ if (IsRedirectingConsole)
|
|
|
|
+ Console.SetOut(this);
|
|
|
|
+
|
|
Trace.Listeners.Add(traceListener);
|
|
Trace.Listeners.Add(traceListener);
|
|
|
|
|
|
_enabled = true;
|
|
_enabled = true;
|
|
@@ -46,7 +54,9 @@ namespace BepInEx.Logger
|
|
if (!Enabled)
|
|
if (!Enabled)
|
|
return;
|
|
return;
|
|
|
|
|
|
- Console.SetOut(stdout);
|
|
|
|
|
|
+ if (IsRedirectingConsole)
|
|
|
|
+ Console.SetOut(stdout);
|
|
|
|
+
|
|
Trace.Listeners.Remove(traceListener);
|
|
Trace.Listeners.Remove(traceListener);
|
|
|
|
|
|
_enabled = false;
|
|
_enabled = false;
|
|
@@ -73,7 +83,6 @@ namespace BepInEx.Logger
|
|
public override string ToString()
|
|
public override string ToString()
|
|
{
|
|
{
|
|
return StringBuilder.ToString().Trim();
|
|
return StringBuilder.ToString().Trim();
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|