Table of Contents

Interface IAuditEntryFactory

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

Builds an audit entry with the caller already resolved — an HTTP principal when there is one, the declared AuditActor when there is not.

public interface IAuditEntryFactory

Remarks

Without this, a consumer writing its own entry constructs AuditEntry by hand and passes it to Log(AuditEntry), which never consults the ambient actor — so background work could declare an actor and still write entries attributed to nobody. Build entries here and hand the result to the logger.

Methods

Create(string, string, string, long, bool, string, string, IReadOnlyDictionary<string, string>)

Builds an entry for a consumer-defined operation, with the caller filled in. The entry is recorded as ServiceCall.

AuditEntry Create(string feature, string action, string methodName = null, long durationMs = 0, bool success = true, string errorMessage = null, string teamKey = null, IReadOnlyDictionary<string, string> metadata = null)

Parameters

feature string

The area acted on — the left half of a scope, e.g. "job".

action string

What was done — the right half, e.g. "claim".

methodName string

Optional method or step name, for the log's Method column.

durationMs long

How long the operation took, if measured.

success bool

Whether it succeeded. False routes it to the failure styling in the log view.

errorMessage string

Why it failed, shown in the failure tooltip and the exports.

teamKey string

The team acted on. Supply it for background work — there is no selected team to infer.

metadata IReadOnlyDictionary<string, string>

What changed, surfaced in the log's detail row.

Returns

AuditEntry

Remarks

Prefer the overload taking an AuditEventType for anything that changed something. The enforcement proxies record their per-call access traces as ServiceCall too, so an entry written through this overload cannot be told apart from them by the Event filter — and on a busy tenant the traces outnumber the domain entries several times over.

Create(AuditEventType, string, string, string, long, bool, string, string, IReadOnlyDictionary<string, string>)

Builds an entry classified as eventType, so a reader can tell what someone did from what someone was permitted to call.

AuditEntry Create(AuditEventType eventType, string feature, string action, string methodName = null, long durationMs = 0, bool success = true, string errorMessage = null, string teamKey = null, IReadOnlyDictionary<string, string> metadata = null)

Parameters

eventType AuditEventType

How to classify the entry, e.g. DataChange.

feature string

The area acted on — the left half of a scope, e.g. "job".

action string

What was done — the right half, e.g. "claim".

methodName string

Optional method or step name, for the log's Method column.

durationMs long

How long the operation took, if measured.

success bool

Whether it succeeded. False routes it to the failure styling in the log view.

errorMessage string

Why it failed, shown in the failure tooltip and the exports.

teamKey string

The team acted on. Supply it for background work — there is no selected team to infer.

metadata IReadOnlyDictionary<string, string>

What changed, surfaced in the log's detail row.

Returns

AuditEntry

Remarks

The event type is what makes the log's Event filter useful to a consumer. Without it every consumer-written entry lands as ServiceCall — the same value the scope proxy writes for each authorized call — and the one distinction a reader cares about is the one the filter cannot express. Use DataChange for an operation that altered something.

The event type does not change how the entry is stored, retained or authorized. It is a classification for reading, and it is free-standing: the enforcement proxies keep writing their own entries for the same call regardless.