Browse Source

Improved StandardLogger's printer initialization

pull/1/head
Anairkoen Schno 5 years ago
parent
commit
c94527197d
2 changed files with 29 additions and 19 deletions
  1. +29
    -19
      IPA.Loader/Logging/StandardLogger.cs
  2. BIN
      Refs/UnityEngine.CoreModule.dll

+ 29
- 19
IPA.Loader/Logging/StandardLogger.cs View File

@ -188,38 +188,48 @@ namespace IPA.Logging
/// </summary> /// </summary>
private static void LogThread() private static void LogThread()
{ {
AppDomain.CurrentDomain.ProcessExit += (sender, args) =>
{
StopLogThread();
};
var started = new HashSet<LogPrinter>(); var started = new HashSet<LogPrinter>();
while (logQueue.TryTake(out var msg, Timeout.Infinite)) while (logQueue.TryTake(out var msg, Timeout.Infinite))
{ {
var logger = msg.Logger;
IEnumerable<LogPrinter> printers = logger.printers;
do do
{ {
logger = logger.parent;
if (logger != null)
printers = printers.Concat(logger.printers);
} while (logger != null);
var logger = msg.Logger;
IEnumerable<LogPrinter> printers = logger.printers;
do
{
logger = logger.parent;
if (logger != null)
printers = printers.Concat(logger.printers);
} while (logger != null);
foreach (var printer in printers.Concat(defaultPrinters))
{
try
foreach (var printer in printers.Concat(defaultPrinters))
{ {
if (((byte)msg.Level & (byte)printer.Filter) != 0)
try
{ {
if (!started.Contains(printer))
if (((byte) msg.Level & (byte) printer.Filter) != 0)
{ {
printer.StartPrint();
started.Add(printer);
}
if (!started.Contains(printer))
{
printer.StartPrint();
started.Add(printer);
}
printer.Print(msg.Level, msg.Time, msg.Logger.logName, msg.Message);
printer.Print(msg.Level, msg.Time, msg.Logger.logName, msg.Message);
}
}
catch (Exception e)
{
Console.WriteLine($"printer errored: {e}");
} }
}
catch (Exception e)
{
Console.WriteLine($"printer errored: {e}");
} }
} }
// wait for messages for 500ms before ending the prints
while (logQueue.TryTake(out msg, TimeSpan.FromMilliseconds(500)));
if (logQueue.Count == 0) if (logQueue.Count == 0)
{ {


BIN
Refs/UnityEngine.CoreModule.dll View File


Loading…
Cancel
Save