Skip to content

Commit 8551ee7

Browse files
LogError feature added in Centralized Logging SDK. Authorized Logerror and gellallerrors apis. Seed data updated for Integration Portal.
1 parent d42a964 commit 8551ee7

File tree

14 files changed

+345
-306
lines changed

14 files changed

+345
-306
lines changed

ApiIntegrationMvc/ApiIntegrationMvc.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
<ItemGroup>
1515
<Folder Include="Areas\Admin\Models\" />
16-
<Folder Include="Areas\Admin\Views\" />
1716
<Folder Include="Areas\Home\Models\" />
1817
<Folder Include="Controllers\" />
1918
</ItemGroup>

ApiIntegrationMvc/Areas/Account/Controllers/LoginController.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using ApiIntegrationMvc.Areas.Account.Models;
2+
using CentralizedLogging.Contracts.DTO;
3+
using CentralizedLogging.Sdk.Abstractions;
24
using Microsoft.AspNetCore.Authentication;
35
using Microsoft.AspNetCore.Authentication.Cookies;
46
using Microsoft.AspNetCore.Mvc;
@@ -13,9 +15,11 @@ namespace ApiIntegrationMvc.Areas.Account.Controllers
1315
public class LoginController : Controller
1416
{
1517
private readonly IUserManagementClient _users;
16-
private readonly IAccessTokenProvider _cache;
18+
private readonly UserManagement.Sdk.Abstractions.IAccessTokenProvider _cache;
1719
private readonly IHttpContextAccessor _http;
18-
public LoginController(IUserManagementClient users, IAccessTokenProvider cache, IHttpContextAccessor http) => (_users, _cache, _http) = (users, cache, http);
20+
private readonly ICentralizedLoggingClient _centralizedlogs;
21+
public LoginController(IUserManagementClient users, ICentralizedLoggingClient centralizedlogs,
22+
UserManagement.Sdk.Abstractions.IAccessTokenProvider cache, IHttpContextAccessor http) => (_users, _centralizedlogs, _cache, _http) = (users, centralizedlogs, cache, http);
1923

2024
[HttpGet]
2125
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
@@ -74,7 +78,8 @@ await HttpContext.SignInAsync(
7478
return RedirectToAction("Index", "Home", new { area = "Home" });
7579
}
7680
catch (HttpRequestException hx)
77-
{
81+
{
82+
await _centralizedlogs.LogErrorAsync(BuildDto(hx, requestPath: "GET api/users"), ct);
7883
TempData["Error"] = hx.Message;
7984
return RedirectToAction(nameof(Index)); // ← PRG on failure
8085
}
@@ -90,6 +95,21 @@ await HttpContext.SignInAsync(
9095
}
9196
}
9297

98+
private CreateErrorLogDto BuildDto(HttpRequestException ex, string requestPath)
99+
{
100+
//=>
101+
CreateErrorLogDto obj = new CreateErrorLogDto
102+
{
103+
ApplicationId = 4,
104+
Severity = "Error",
105+
Message = ex.Message,
106+
StackTrace = ex.ToString(),
107+
Source = ex.Source,
108+
RequestId = Guid.NewGuid().ToString(), // or pass one down
109+
};
110+
return obj;
111+
}
112+
93113
private static string? Claim(ClaimsPrincipal? u, string t) => u?.FindFirst(t)?.Value;
94114

95115
private string? CurrentUserId() =>

ApiIntegrationMvc/Areas/Account/Views/Login/Index.cshtml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,42 @@
55
}
66

77
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
8-
<style>
9-
/* Page-specific centering */
10-
.login-container {
11-
height: 100vh;
12-
display: flex;
13-
justify-content: center; /* horizontal */
14-
align-items: center; /* vertical */
8+
@section Styles{
9+
<style>
10+
/* Page-specific centering */
11+
.login-container {
12+
height: 100vh;
13+
display: flex;
14+
justify-content: center; /* horizontal */
15+
align-items: center; /* vertical */
1516
16-
}
17+
}
1718
18-
body {
19-
margin-bottom: 60px;
20-
background: linear-gradient(135deg, #f8f9fa, #e9ecef);
21-
}
19+
body {
20+
margin-bottom: 60px;
21+
background: linear-gradient(135deg, #f8f9fa, #e9ecef);
22+
}
2223
23-
.login-card {
24-
width: 100%;
25-
max-width: 400px;
26-
background: #fff;
27-
border-radius: 12px;
28-
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
29-
padding: 2rem;
30-
}
24+
.login-card {
25+
width: 100%;
26+
max-width: 400px;
27+
background: #fff;
28+
border-radius: 12px;
29+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
30+
padding: 2rem;
31+
}
3132
32-
.login-card h2 {
33-
font-weight: 600;
34-
color: #2c3e50;
35-
}
33+
.login-card h2 {
34+
font-weight: 600;
35+
color: #2c3e50;
36+
}
3637
37-
.alert {
38-
border-radius: 8px;
39-
margin-top: 1rem;
40-
}
41-
</style>
42-
38+
.alert {
39+
border-radius: 8px;
40+
margin-top: 1rem;
41+
}
42+
</style>
43+
}
4344
<div class="login-container">
4445
<div class="login-card text-center">
4546
<h2 class="mb-4">🔗 Integration Portal</h2>

ApiIntegrationMvc/Areas/Admin/Controllers/LogsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public async Task<IActionResult> Index(CancellationToken ct)
1818
var result = await _centralizedlogs.GetAllErrorAsync(ct);
1919

2020

21-
return View();
21+
return View(result);
2222
}
2323
}
2424
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@using ApiIntegrationMvc
2+
@using ApiIntegrationMvc.Models
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@using ApiIntegrationMvc.Areas.Account.Models
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = "~/Views/Shared/_Layout.cshtml"; // or area-specific layout if you want
3+
}

0 commit comments

Comments
 (0)