2012-01-22 18:24:16 -08:00
|
|
|
using System;
|
|
|
|
using System.Text;
|
|
|
|
using System.Web.Mvc;
|
|
|
|
using NzbDrone.Common;
|
2010-10-24 00:46:58 -07:00
|
|
|
using NzbDrone.Core.Instrumentation;
|
2011-08-21 18:00:12 -07:00
|
|
|
using NzbDrone.Web.Models;
|
2010-10-24 00:46:58 -07:00
|
|
|
using Telerik.Web.Mvc;
|
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
{
|
|
|
|
public class LogController : Controller
|
|
|
|
{
|
2011-04-09 17:14:51 -07:00
|
|
|
private readonly LogProvider _logProvider;
|
2012-01-22 18:24:16 -08:00
|
|
|
private readonly EnviromentProvider _enviromentProvider;
|
|
|
|
private readonly DiskProvider _diskProvider;
|
2010-10-24 00:46:58 -07:00
|
|
|
|
2012-01-22 18:24:16 -08:00
|
|
|
public LogController(LogProvider logProvider, EnviromentProvider enviromentProvider, DiskProvider diskProvider)
|
2010-10-24 00:46:58 -07:00
|
|
|
{
|
|
|
|
_logProvider = logProvider;
|
2012-01-22 18:24:16 -08:00
|
|
|
_enviromentProvider = enviromentProvider;
|
|
|
|
_diskProvider = diskProvider;
|
2010-10-24 00:46:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public ActionResult Index()
|
|
|
|
{
|
|
|
|
return View();
|
|
|
|
}
|
|
|
|
|
2012-01-22 18:24:16 -08:00
|
|
|
public FileContentResult File()
|
|
|
|
{
|
|
|
|
string log = string.Empty;
|
|
|
|
|
|
|
|
if (_diskProvider.FileExists(_enviromentProvider.GetArchivedLogFileName()))
|
|
|
|
{
|
|
|
|
log = _diskProvider.ReadAllText(_enviromentProvider.GetArchivedLogFileName());
|
|
|
|
}
|
|
|
|
|
|
|
|
log += _diskProvider.ReadAllText(_enviromentProvider.GetLogFileName());
|
|
|
|
|
|
|
|
return new FileContentResult(Encoding.ASCII.GetBytes(log), "text/plain");
|
|
|
|
}
|
|
|
|
|
2011-08-05 19:04:35 -07:00
|
|
|
public JsonResult Clear()
|
2010-10-24 00:46:58 -07:00
|
|
|
{
|
|
|
|
_logProvider.DeleteAll();
|
2011-08-05 19:04:35 -07:00
|
|
|
|
2012-01-18 21:01:47 -08:00
|
|
|
return JsonNotificationResult.Info("Logs Cleared");
|
2011-09-05 12:59:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
[GridAction]
|
2011-11-22 22:41:38 -08:00
|
|
|
public ActionResult AjaxBinding()
|
2011-09-05 12:59:39 -07:00
|
|
|
{
|
2011-11-22 21:58:26 -08:00
|
|
|
return View(new GridModel(_logProvider.GetAllLogs()));
|
2010-10-24 00:46:58 -07:00
|
|
|
}
|
|
|
|
}
|
2011-04-09 19:44:01 -07:00
|
|
|
}
|