Skip to content

Commit

Permalink
Add extra logging to debug error when page changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamerst committed Oct 30, 2022
1 parent fe2f72d commit 8896ef7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion jobhunt/Data/JobHuntContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
// });

// optionsBuilder.UseLoggerFactory(loggerFactory);
// optionsBuilder.EnableSensitiveDataLogging();

optionsBuilder.EnableSensitiveDataLogging();

// disable global query filter warning for related entries
// without this a warning is thrown at every start for the JobCategories entity
Expand Down
13 changes: 11 additions & 2 deletions jobhunt/PageWatcher/PageWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,21 @@ await _wpcService.CreateAsync(new WatchedPageChange
{
changed = true;

WatchedPageChange? change = await _wpcService.CreateAsync(new WatchedPageChange
WatchedPageChange change = new WatchedPageChange
{
WatchedPageId = page.Id,
Created = DateTimeOffset.UtcNow,
Html = response
});
};

try
{
await _wpcService.CreateAsync(change);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to save page change {@change}", change);
}

if (change != null)
{
Expand Down
4 changes: 2 additions & 2 deletions jobhunt/Services/BaseServices/BaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public BaseService(JobHuntContext context)

public Task<int> SaveChangesAsync() => _context.SaveChangesAsync();

public virtual async Task<T?> CreateAsync(T entity)
public virtual async Task<T> CreateAsync(T entity)
{
Set.Add(entity);

Expand All @@ -35,6 +35,6 @@ public interface IBaseService<T> where T : class, KeyedEntity
{
DbSet<T> Set { get; }
Task<int> SaveChangesAsync();
Task<T?> CreateAsync(T entity);
Task<T> CreateAsync(T entity);
Task<T> BeforeSaveAsync(T entity);
}

0 comments on commit 8896ef7

Please sign in to comment.