2012-07-30 13:44:28 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Logging
|
|
|
|
|
{
|
2012-07-30 19:03:07 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides a Logger that can write to any Stream
|
|
|
|
|
/// </summary>
|
2012-07-30 13:44:28 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|