Fixed string formatting in logger

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-06 09:21:14 -04:00
parent 307d725714
commit 2b188c4ac9

View File

@ -36,7 +36,7 @@ namespace MediaBrowser.Common.Logging
Environment.NewLine);
}
message = string.Format(message, paramList);
message = FormatMessage(message, paramList);
LogError(string.Format("{0} ( {1} )", message, builder));
}
@ -46,11 +46,24 @@ namespace MediaBrowser.Common.Logging
LogEntry(message, LogSeverity.Warning, paramList);
}
private string FormatMessage(string message, params object[] paramList)
{
if (paramList != null)
{
for (int i = 0; i < paramList.Length; i++)
{
message = message.Replace("{" + i + "}", paramList[i].ToString());
}
}
return message;
}
private void LogEntry(string message, LogSeverity severity, params object[] paramList)
{
if (severity < LogSeverity) return;
message = string.Format(message, paramList);
message = FormatMessage(message, paramList);
Thread currentThread = Thread.CurrentThread;