Skip to content

Commit 97750ec

Browse files
committed
adds logging
1 parent b6008fa commit 97750ec

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Ghosts.Api/Controllers/ClientUpdatesController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Ghosts.Api.Controllers
2020
[Route("api/[controller]")]
2121
public class ClientUpdatesController : Controller
2222
{
23-
private static readonly Logger log = LogManager.GetCurrentClassLogger();
23+
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
2424
private readonly IBackgroundQueue _queue;
2525
private readonly IMachineUpdateService _updateService;
2626
private readonly IMachineService _machineService;
@@ -47,7 +47,7 @@ public ClientUpdatesController(IMachineService machineService, IMachineUpdateSer
4747
public async Task<IActionResult> Index(CancellationToken ct)
4848
{
4949
var id = Request.Headers["ghosts-id"];
50-
log.Trace($"Request by {id}");
50+
_log.Trace($"Request by {id}");
5151

5252
var findMachineResponse = await this._machineService.FindOrCreate(HttpContext, ct);
5353
if (!findMachineResponse.IsValid())
@@ -74,7 +74,7 @@ public async Task<IActionResult> Index(CancellationToken ct)
7474
var u = await _updateService.GetAsync(m.Id, m.CurrentUsername, ct);
7575
if (u == null) return NotFound();
7676

77-
log.Trace($"Update sent to {m.Id} {m.FQDN} {u.Id} {u.Username} {u.Update}");
77+
_log.Trace($"Update sent to {m.Id} {m.FQDN} {u.Id} {u.Username} {u.Update}");
7878

7979
var update = new UpdateClientConfig { Type = u.Type, Update = u.Update };
8080

src/Ghosts.Api/Controllers/MachineUpdatesController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Ghosts.Api.Controllers
2121
[Route("api/[controller]")]
2222
public class MachineUpdatesController : Controller
2323
{
24-
private static readonly Logger log = LogManager.GetCurrentClassLogger();
24+
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
2525
private readonly IBackgroundQueue _queue;
2626
private readonly IMachineUpdateService _updateService;
2727

src/Ghosts.Api/Infrastructure/Services/MachineUpdateService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,24 @@ public async Task<MachineUpdate> GetAsync(Guid machineId, string currentUsername
6666
var update = await _context.MachineUpdates
6767
.FirstOrDefaultAsync(m => (m.MachineId == machineId) && m.ActiveUtc < DateTime.UtcNow && m.Status == StatusType.Active, ct);
6868

69+
_log.Trace($"Update by machine id {machineId} is {update == null}");
70+
6971
if (update != null && !string.IsNullOrEmpty(update.Update))
7072
{
7173
// if the username is there, but the machine id is not
7274
if (!string.IsNullOrEmpty(currentUsername) && machineId == Guid.Empty)
7375
{
7476
update = await _context.MachineUpdates
7577
.FirstOrDefaultAsync(m => (m.Username.ToLower().StartsWith(currentUsername.ToLower())) && m.ActiveUtc < DateTime.UtcNow && m.Status == StatusType.Active, ct);
78+
_log.Trace($"Update by username {currentUsername} is {update == null}");
7679
}
7780
else // pick either
7881
{
7982
update = await _context.MachineUpdates
8083
.FirstOrDefaultAsync(
8184
m => (m.MachineId == machineId || m.Username.ToLower().StartsWith(currentUsername.ToLower())) &&
8285
m.ActiveUtc < DateTime.UtcNow && m.Status == StatusType.Active, ct);
86+
_log.Trace($"Update by either {machineId} or {currentUsername} is {update == null}");
8387
}
8488
}
8589

0 commit comments

Comments
 (0)