/// <summary> /// Gets the entries. /// </summary> /// <param name="logFileName">Name of the log file.</param> /// <param name="page">The page.</param> /// <param name="searchQuery">The search query.</param> /// <returns></returns> public PagingResult <LogEntry> GetEntries(string logFileName, int?page = null, string searchQuery = null) { string location = ApplicationSettings.Current.AlternateLogLocation; bool showError = !string.IsNullOrWhiteSpace(location); PagingResult <LogEntry> entries = new PagingResult <LogEntry>(); int pagingSize = ApplicationSettings.Current.DefaultPagingSize; this.TryExecute( () => { ILogsClient client = this.factory.Create <ILogsClient>(); entries = client.GetLogEntries(logFileName, page, searchQuery, pagingSize); }, () => { if (!string.IsNullOrWhiteSpace(location)) { var logs = new List <LogEntry>(); logLoader.LoadLogs(logs, Path.Combine(ApplicationSettings.Current.AlternateLogLocation, logFileName)); entries = LogLoader.FilterLogs(logs, page, searchQuery, pagingSize); } }, showError); return(entries); }
/// <summary> /// Gets the entries. GET /logs/[logname]?page=&search= /// </summary> /// <param name="id">The identifier.</param> /// <param name="page">The page.</param> /// <param name="search">The search.</param> /// <param name="size">The paging sizesize.</param> /// <returns></returns> /// <exception cref="System.Web.Http.HttpResponseException">Thrown when the log is not found.</exception> public PagingResult <LogEntry> GetEntries(string id, int?page = null, string search = null, int size = 0) { log.Debug(string.Format("(API) Log -> GetEntries - {0}", id)); // id maps to the file name string fullPath = GetFullLogPath(id); IList <LogEntry> logs = new List <LogEntry>(); try { logLoader.LoadLogs(logs, fullPath); } catch (FileNotFoundException) { throw new HttpResponseException(HttpStatusCode.NotFound); } catch (IOException) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } return(LogLoader.FilterLogs(logs, page, search, size)); }