2012-07-30 13:44:28 +00:00
|
|
|
|
using System;
|
2012-08-22 20:07:16 +00:00
|
|
|
|
using System.Collections.Generic;
|
2012-07-30 13:44:28 +00:00
|
|
|
|
|
2012-07-31 03:38:00 +00:00
|
|
|
|
namespace MediaBrowser.Common.Logging
|
2012-07-30 13:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
public struct LogRow
|
|
|
|
|
{
|
|
|
|
|
const string TimePattern = "h:mm:ss.fff tt d/M/yyyy";
|
|
|
|
|
|
|
|
|
|
public LogSeverity Severity { get; set; }
|
|
|
|
|
public string Message { get; set; }
|
|
|
|
|
public int ThreadId { get; set; }
|
|
|
|
|
public string ThreadName { get; set; }
|
|
|
|
|
public DateTime Time { get; set; }
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2012-09-11 18:20:12 +00:00
|
|
|
|
var data = new List<string>();
|
2012-08-22 20:07:16 +00:00
|
|
|
|
|
|
|
|
|
data.Add(Time.ToString(TimePattern));
|
|
|
|
|
|
|
|
|
|
data.Add(Severity.ToString());
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Message))
|
|
|
|
|
{
|
|
|
|
|
data.Add(Encode(Message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.Add(ThreadId.ToString());
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(ThreadName))
|
|
|
|
|
{
|
|
|
|
|
data.Add(Encode(ThreadName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Join(" , ", data.ToArray());
|
2012-07-30 13:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string Encode(string str)
|
|
|
|
|
{
|
|
|
|
|
return (str ?? "").Replace(",", ",,").Replace(Environment.NewLine, " [n] ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|