refactor logging in pretty big overhaul
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Dtos;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WebfrontCore.Controllers.API.Dtos;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
|
||||
namespace WebfrontCore.Controllers.API
|
||||
{
|
||||
@ -20,7 +21,7 @@ namespace WebfrontCore.Controllers.API
|
||||
private readonly IResourceQueryHelper<FindClientRequest, FindClientResult> _clientQueryHelper;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ClientController(ILogger logger, IResourceQueryHelper<FindClientRequest, FindClientResult> clientQueryHelper)
|
||||
public ClientController(ILogger<ClientController> logger, IResourceQueryHelper<FindClientRequest, FindClientResult> clientQueryHelper)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientQueryHelper = clientQueryHelper;
|
||||
@ -53,8 +54,7 @@ namespace WebfrontCore.Controllers.API
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.WriteWarning($"Failed to retrieve clients with query - {request.ToDebugString()}");
|
||||
_logger.WriteDebug(e.GetExceptionInfo());
|
||||
_logger.LogWarning(e, "Failed to retrieve clients with query - {@request}", request);
|
||||
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, new ErrorResponse()
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
var meta = await ProfileMetaListViewComponent.GetClientMeta(_metaService, metaFilterType, Client.Level, request);
|
||||
|
||||
if (meta.Count() == 0)
|
||||
if (!meta.Any())
|
||||
{
|
||||
return Ok();
|
||||
}
|
||||
|
@ -3,19 +3,22 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Dtos;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static SharedLibraryCore.Server;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
|
||||
namespace WebfrontCore.Controllers
|
||||
{
|
||||
public class HomeController : BaseController
|
||||
{
|
||||
private readonly ITranslationLookup _translationLookup;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public HomeController(IManager manager, ITranslationLookup translationLookup) : base(manager)
|
||||
public HomeController(ILogger<HomeController> logger, IManager manager, ITranslationLookup translationLookup) : base(manager)
|
||||
{
|
||||
_logger = logger;
|
||||
_translationLookup = translationLookup;
|
||||
}
|
||||
|
||||
@ -43,10 +46,7 @@ namespace WebfrontCore.Controllers
|
||||
public IActionResult Error()
|
||||
{
|
||||
var exceptionFeature = HttpContext.Features.Get<IExceptionHandlerPathFeature>();
|
||||
Manager.GetLogger(0).WriteError($"[Webfront] {exceptionFeature.Error.Message}");
|
||||
Manager.GetLogger(0).WriteDebug(exceptionFeature.Path);
|
||||
Manager.GetLogger(0).WriteDebug(exceptionFeature.Error.StackTrace);
|
||||
|
||||
_logger.LogError("[Webfront] {path} {message} {@exception}", exceptionFeature.Path, exceptionFeature.Error.Message, exceptionFeature.Error);
|
||||
ViewBag.Description = Localization["WEBFRONT_ERROR_DESC"];
|
||||
ViewBag.Title = Localization["WEBFRONT_ERROR_TITLE"];
|
||||
return View(exceptionFeature.Error);
|
||||
|
Reference in New Issue
Block a user