public ActionResult LogViewerByModel(LogViewerModel model) { if (WebGrid<LogMessageModel, LogViewerModel, DataFilterLogger>.IsWebGridEvent()) { this.ModelState.Clear(); model.Filter = (DataFilterLogger)WebGrid<LogMessageModel, LogViewerModel, DataFilterLogger>.GetDataFilterFromPost(); model.Filter.IsClientVisible = false; } model = this.LogViewerSetBreadcrumb(model, model.Filter.LogTraceSourceSelected, model.Filter.LogTraceListenerSelected); LogWriterFactory logWriterFactory = new LogWriterFactory(); LogWriter logWriterInstance = logWriterFactory.Create(); using (TraceListener traceListenerInstance = logWriterInstance.TraceSources[model.Filter.LogTraceSourceSelected] .Listeners.Where(p => p.Name == model.Filter.LogTraceListenerSelected).First()) { if (traceListenerInstance is ICustomTraceListener) { model.LogMessages = ((ICustomTraceListener)traceListenerInstance).SearchLogMessages(LogginConfigurationSectionName, model.Filter); //model.Filter.NextContinuationToken = model.LogMessages.NextContinuationToken; //model.Filter.PreviousContinuationToken = model.LogMessages.PreviousContinuationToken; return View(LogViewerViewHelper.LogViewerDisplay, model); } else { throw new Exception("TraceListener Not Supported"); } } }
void messages_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (ILogMessage message in e.NewItems) { LogViewerModel log = new LogViewerModel(message.Message, message.Category, message.Priority, message.Timestamp); logs.Add(log); } this.lastEntry = logs.Last(); } }
public LogViewerViewModel(ILogViewerLogger logger) { logs = new ObservableCollection <LogViewerModel>(); messages = logger.Messages; messages.CollectionChanged += messages_CollectionChanged; foreach (ILogMessage message in messages) { LogViewerModel log = new LogViewerModel(message.Message, message.Category, message.Priority, message.Timestamp); logs.Add(log); } this.lastEntry = logs.Last(); }
public ActionResult LogViewerById(string guid) { LogViewerModel model = new LogViewerModel(); using (ILoggingProxy provider = DependencyFactory.Resolve<ILoggingProxy>()) { model.BaseViewModelInfo.Title = GeneralTexts.LogViewer; model.LogMessages = new DataResultLogMessageList() { Data = provider.LoggingExceptionGetById(Guid.Parse(guid)).Data }; } return View(LogViewerViewHelper.LogViewerById, model); }
// GET: LogViewer public ActionResult Index(int skip = 0, int count = 100, LogLevel?logLevel = null, string query = null, string applicationQuery = null, string environment = null) { var node = MvcApplication.Configuration.GetNodeForEnviroment(environment); var cred = node.DbCredentials; if (string.IsNullOrEmpty(applicationQuery)) { applicationQuery = null; } if (string.IsNullOrEmpty(query)) { query = null; } var res = _logRepository.GetLatest(cred, logLevel, skip, count, query, applicationQuery).ToList(); while (skip >= count && res.Count == 0) { skip -= count; res = _logRepository.GetLatest(cred, logLevel, skip, count, query, applicationQuery).ToList(); } var model = new LogViewerModel { ApplicationNames = _appNames, Count = count, Skip = skip, Entries = res, LogLevel = logLevel, ActiveLevels = _logRepository.GetActiveLevels(cred), ApplicationQuery = applicationQuery, Query = query, Environment = environment, Environments = MvcApplication.Configuration.Nodes.Select(c => c.Name).ToList(), EnvironmentApiRoot = new Uri($"http://{node.ClusterHost}") }; return(View(model)); }
private LogViewerModel LogViewerSetBreadcrumb(LogViewerModel model, string traceSourceName, string traceListenerName) { model.BaseViewModelInfo.Breadcrumb.IsVisible = true; model.BaseViewModelInfo.Breadcrumb.BreadcrumbPaths.AddRange(new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>(Resources.General.GeneralTexts.Dashboard, Url.Account_Dashboard()), new KeyValuePair<string, string>(Resources.General.GeneralTexts.LogViewer, Url.LogViewer()), new KeyValuePair<string, string>(string.Format("{0}", traceSourceName), Url.LogViewerBySourceName(traceSourceName)), }); return model; }
private LogViewerModel LogViewerModel_GetBaseModel(string sourceName, string listenerName) { LogViewerModel model = new LogViewerModel(); model.BaseViewModelInfo.Title = GeneralTexts.LogViewer; model.LogTraceSources = (ConfigurationManager.GetSection(LogginConfigurationSectionName) as LoggingSettings).TraceSources; if (!string.IsNullOrEmpty(sourceName)) { if (!model.LogTraceSources.Contains(sourceName)) { throw new Exception("Trace Data Source Not Found"); } model.Filter = new DataFilterLogger() { LogTraceSourceSelected = sourceName, CreationDate = DateTime.Now, //CreationDateTo = DateTime.Now, IsClientVisible = true, Page = 0, PageSize = (int)PageSizesAvailable.RowsPerPage10, SortAscending = true, SortBy = string.Empty }; model.LogTraceListeners = model.LogTraceSources.Where(x => x.Name == sourceName).First().TraceListeners; if (!string.IsNullOrEmpty(listenerName)) { model.Filter.LogTraceListenerSelected = listenerName; if (!model.LogTraceListeners.Contains(listenerName)) { throw new Exception("Trace Data Source Not Found"); } } } return model; }