TopLogs will now return the count pass in, reduced to 5000 from 7500 to prevent JsonSerialization issues when being sent to the grid.

Added tests for TopLogs and GetPagedLogs.
This commit is contained in:
Mark McDowall 2011-09-07 17:01:51 -07:00
commit 070115a59a
3 changed files with 77 additions and 11 deletions

View file

@ -22,15 +22,15 @@ namespace NzbDrone.Core.Instrumentation
return _database.Fetch<Log>();
}
public IList<Log> TopLogs()
public IList<Log> TopLogs(int count)
{
var logs = _database.Fetch<Log>("SELECT TOP 7500 * FROM Logs ORDER BY Time Desc");
var logs = _database.Fetch<Log>("SELECT TOP " + count + " * FROM Logs ORDER BY Time Desc");
logs.Add(new Log
{
Time = DateTime.Now.AddYears(-100),
Level = "Info",
Logger = "NzbDrone.Core.Instrumentation.LogProvider",
Message = String.Format("Number of logs currently shown: 7500. More may exist, check 'All' to see everything")
Logger = "Core.Instrumentation.LogProvider",
Message = String.Format("Number of logs currently shown: {0}. More may exist, check 'All' to see everything", Math.Min(count, logs.Count))
});
return logs;