mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-27 03:04:49 +03:00
Extracted Logging into a separate, portable class library
This commit is contained in:
parent
882e20e9a5
commit
7766956274
32
MediaBrowser.Logging/StreamLogger.cs
Normal file
32
MediaBrowser.Logging/StreamLogger.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.Logging
|
||||
{
|
||||
public class StreamLogger : BaseLogger
|
||||
{
|
||||
private Stream Stream { get; set; }
|
||||
|
||||
public StreamLogger(Stream stream)
|
||||
: base()
|
||||
{
|
||||
Stream = stream;
|
||||
}
|
||||
|
||||
protected override void LogEntry(LogRow row)
|
||||
{
|
||||
byte[] bytes = new UTF8Encoding().GetBytes(row.ToString() + Environment.NewLine);
|
||||
|
||||
Stream.Write(bytes, 0, bytes.Length);
|
||||
Stream.Flush();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
Stream.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user