mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-08 03:28:33 +00:00
36 lines
711 B
C#
36 lines
711 B
C#
|
using System.IO;
|
|||
|
using Utf8Json;
|
|||
|
|
|||
|
namespace Ryujinx.Common.Logging
|
|||
|
{
|
|||
|
public class JsonLogTarget : ILogTarget
|
|||
|
{
|
|||
|
private Stream _stream;
|
|||
|
private bool _leaveOpen;
|
|||
|
|
|||
|
public JsonLogTarget(Stream stream)
|
|||
|
{
|
|||
|
_stream = stream;
|
|||
|
}
|
|||
|
|
|||
|
public JsonLogTarget(Stream stream, bool leaveOpen)
|
|||
|
{
|
|||
|
_stream = stream;
|
|||
|
_leaveOpen = leaveOpen;
|
|||
|
}
|
|||
|
|
|||
|
public void Log(object sender, LogEventArgs e)
|
|||
|
{
|
|||
|
JsonSerializer.Serialize(_stream, e);
|
|||
|
}
|
|||
|
|
|||
|
public void Dispose()
|
|||
|
{
|
|||
|
if (!_leaveOpen)
|
|||
|
{
|
|||
|
_stream.Dispose();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|