Example #1
0
        public async Task <IActionResult> Logs(LogMessagesFilterViewModel model)
        {
            if (model.Id.HasValue)
            {
                return(RedirectToActionPermanent("Log", new { id = model.Id.Value }));
            }

            try
            {
                ViewBag.Messages = await _loggingService.GetLogMessagesAsync(model.ToLogMessagesFilterModel());
            }
            catch (System.Exception e)
            {
                _logger.LogWarning(LoggingEvents.HomeController.AsInt(), e, "Bad filter for logs");
                return(BadRequest("Bad filter parameters"));
            }

            ViewBag.FilterData = await _loggingService.GetAvailableFilterDataAsync();

            if (ViewBag.Messages.Count == 0)
            {
                TempData["MessageSeverity"] = "warning";
                TempData["MessageContent"]  = $"No log messages found in the system.";
            }

            return(View(model));
        }
Example #2
0
        public async Task <IActionResult> GetLogMessages(LogMessagesFilterViewModel model)
        {
            var messages = (await _loggingService
                            .GetLogMessagesAsync(
                                model.ToLogMessagesFilterModel()
                                ))
                           .Select(msg => new
            {
                msg.AuxiliaryData,
                msg.Id,
                msg.Message,
                Severity = msg.Severity.Description,
                msg.Source,
                msg.Timestamp,
                msg.Category
            });

            if (messages.Count() == 0)
            {
                return(NoContent());
            }
            else
            {
                return(Json(messages));
            }
        }