Fix LogWindow treating everything as ascii
hopefully this doesn't break anything
This commit is contained in:
parent
f11b5bc9c4
commit
3d30f52e7c
|
@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// TODO: only show add to game db when this is a Rom details dialog
|
// TODO: only show add to game db when this is a Rom details dialog
|
||||||
// Let user decide what type (instead of always adding it as a good dump)
|
// Let user decide what type (instead of always adding it as a good dump)
|
||||||
private readonly List<string> _lines = new List<string>();
|
private readonly List<string> _lines = new List<string>();
|
||||||
private LogStream _logStream;
|
private LogWriter _logWriter;
|
||||||
|
|
||||||
[RequiredService]
|
[RequiredService]
|
||||||
private IEmulator Emulator { get; set; }
|
private IEmulator Emulator { get; set; }
|
||||||
|
@ -48,10 +48,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private void Attach()
|
private void Attach()
|
||||||
{
|
{
|
||||||
_logStream = new LogStream();
|
_logWriter = new LogWriter();
|
||||||
Log.HACK_LOG_STREAM = _logStream;
|
Console.SetOut(_logWriter);
|
||||||
Console.SetOut(new StreamWriter(_logStream) { AutoFlush = true });
|
_logWriter.Emit = appendInvoked;
|
||||||
_logStream.Emit = appendInvoked;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Detach()
|
private void Detach()
|
||||||
|
@ -60,9 +59,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
AutoFlush = true
|
AutoFlush = true
|
||||||
});
|
});
|
||||||
_logStream.Close();
|
_logWriter.Close();
|
||||||
_logStream = null;
|
_logWriter = null;
|
||||||
Log.HACK_LOG_STREAM = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowReport(string title, string report)
|
public void ShowReport(string title, string report)
|
||||||
|
@ -208,47 +206,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LogStream : Stream
|
private class LogWriter : TextWriter
|
||||||
{
|
{
|
||||||
public override bool CanRead => false;
|
public override void Write(char[] buffer, int offset, int count)
|
||||||
public override bool CanSeek => false;
|
|
||||||
public override bool CanWrite => true;
|
|
||||||
|
|
||||||
public override void Flush()
|
|
||||||
{
|
{
|
||||||
//TODO - maybe this will help with decoding
|
Emit(new string(buffer, offset, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long Length => throw new NotImplementedException();
|
public override Encoding Encoding => Encoding.Unicode;
|
||||||
|
|
||||||
public override long Position
|
|
||||||
{
|
|
||||||
get => throw new NotImplementedException();
|
|
||||||
set => throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int Read(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Seek(long offset, SeekOrigin origin)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetLength(long value)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
// TODO - buffer undecoded characters (this may be important)
|
|
||||||
//(use decoder = System.Text.Encoding.Unicode.GetDecoder())
|
|
||||||
string str = Encoding.ASCII.GetString(buffer, offset, count);
|
|
||||||
Emit(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action<string> Emit;
|
public Action<string> Emit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,6 @@ namespace BizHawk.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------- Default Logger Action --------------
|
// -------------- Default Logger Action --------------
|
||||||
public static Stream? HACK_LOG_STREAM;
|
|
||||||
|
|
||||||
private static readonly bool LogToConsole = false;
|
private static readonly bool LogToConsole = false;
|
||||||
private static readonly bool LogToFile = false;
|
private static readonly bool LogToFile = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue