Added logging nuget packages to allow for logging capabilities.

This commit is contained in:
Daniel Wathen
2022-12-09 14:17:39 -07:00
parent 32d8ad8b3c
commit 43957fe66d
7 changed files with 91 additions and 8 deletions

View File

@ -15,6 +15,7 @@ namespace ReportingServices.Controllers
public IActionResult Index()
{
_logger.LogInformation("Starting Index Page");
return View();
}

View File

@ -12,16 +12,19 @@ namespace ReportingServices.Controllers
private readonly IJsonFileHandler _jsonFileHandler;
private readonly IScrapeDatabaseRepository _scrapeDatabaseRepository;
private readonly IFabTimeReportingRepository _fabTimeReportingRepository;
private readonly ILogger<ProductionReportController> _logger;
private readonly int _reportIndex = (int)DateTime.Now.DayOfWeek;
private readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json";
private readonly string _toolStateOwnerFilePath = "wwwroot/Assets/ToolStates.json";
private readonly string _toolFilter = "~R76%2C%20~R78%2C%20~R25%2C%20~R67%2C%20~R69%2C%20~R71%2C%20~R47%2C%20~R51%2C%20~R28";
public ProductionReportController(IJsonFileHandler jsonFileHandler, IScrapeDatabaseRepository scrapeDatabaseRepository, IFabTimeReportingRepository fabTimeReportingRepository)
public ProductionReportController(IJsonFileHandler jsonFileHandler, IScrapeDatabaseRepository scrapeDatabaseRepository,
IFabTimeReportingRepository fabTimeReportingRepository, ILogger<ProductionReportController> logger)
{
_jsonFileHandler = jsonFileHandler;
_scrapeDatabaseRepository = scrapeDatabaseRepository;
_fabTimeReportingRepository = fabTimeReportingRepository;
_logger = logger;
}
@ -32,12 +35,21 @@ namespace ReportingServices.Controllers
public IActionResult DailyReport()
{
DailyReport dailyReport = SetUpDailyReport();
Dictionary<string, List<string>> toolStateOwners = _jsonFileHandler.LoadJSONFile<Dictionary<string, List<string>>>(_toolStateOwnerFilePath);
try
{
DailyReport dailyReport = SetUpDailyReport();
Dictionary<string, List<string>> toolStateOwners = _jsonFileHandler.LoadJSONFile<Dictionary<string, List<string>>>(_toolStateOwnerFilePath);
dailyReport.ToolStatesByOwner = toolStateOwners;
dailyReport.ToolStatesByOwner = toolStateOwners;
return View(dailyReport);
return View(dailyReport);
}
catch (Exception ex)
{
_logger.LogCritical(ex, "Failed to load report");
return View();
}
}
public IActionResult EditDailyReport()