fix: add class context to all loggers, format

This commit is contained in:
sam 2024-09-04 14:25:44 +02:00
parent fb324e7576
commit 6c9d1c328b
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
16 changed files with 54 additions and 37 deletions

View file

@ -13,6 +13,8 @@ public class EmailAuthController(
IClock clock,
ILogger logger) : ApiControllerBase
{
private readonly ILogger _logger = logger.ForContext<EmailAuthController>();
[HttpPost("login")]
[ProducesResponseType<AuthController.AuthResponse>(StatusCodes.Status200OK)]
public async Task<IActionResult> LoginAsync([FromBody] LoginRequest req)
@ -23,13 +25,13 @@ public class EmailAuthController(
var frontendApp = await db.GetFrontendApplicationAsync();
logger.Debug("Logging user {Id} in with email and password", user.Id);
_logger.Debug("Logging user {Id} in with email and password", user.Id);
var (tokenStr, token) =
authSvc.GenerateToken(user, frontendApp, ["*"], clock.GetCurrentInstant() + Duration.FromDays(365));
db.Add(token);
logger.Debug("Generated token {TokenId} for {UserId}", user.Id, token.Id);
_logger.Debug("Generated token {TokenId} for {UserId}", token.Id, user.Id);
await db.SaveChangesAsync();