Table of Contents

Class MongoDbAuditLogger

Namespace
Tharga.Team.Service.Audit
Assembly
Tharga.Team.Service.dll

Audit logger that writes to MongoDB via a background channel for zero-latency impact. Resolves IAuditRepositoryCollection lazily to avoid DI issues in test environments.

public class MongoDbAuditLogger : BackgroundService, IHostedService, IDisposable, IAuditLogger
Inheritance
MongoDbAuditLogger
Implements
Inherited Members

Constructors

MongoDbAuditLogger(IServiceProvider, ILogger<MongoDbAuditLogger>, IOptions<AuditOptions>)

public MongoDbAuditLogger(IServiceProvider serviceProvider, ILogger<MongoDbAuditLogger> logger, IOptions<AuditOptions> options = null)

Parameters

serviceProvider IServiceProvider
logger ILogger<MongoDbAuditLogger>
options IOptions<AuditOptions>

Methods

ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

protected override Task ExecuteAsync(CancellationToken stoppingToken)

Parameters

stoppingToken CancellationToken

Triggered when StopAsync(CancellationToken) is called.

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.

Log(AuditEntry)

public void Log(AuditEntry entry)

Parameters

entry AuditEntry

QueryAsync(AuditQuery)

public Task<AuditQueryResult> QueryAsync(AuditQuery query)

Parameters

query AuditQuery

Returns

Task<AuditQueryResult>