# Class AuditLogger

Audit exports - Structured audit logging (Issue #193) Split from index.ts for file size compliance (Issue #285)

#### Implements

- IAuditLogger

- Defined in packages/nexus-agents/src/audit/audit-logger.ts:158

##### Index

### Constructors

constructor

### Methods

log
logToolInvocation
logPolicyDecision
logSecurityEvent
logRateLimitViolation
logSystemStartup
logSystemShutdown
flush
close

## Constructors

### constructor

- new AuditLogger(
  config: {
  logDir: string;
  filePrefix: string;
  maxFileSizeBytes: number;
  maxFiles: number;
  enableHashChain: boolean;
  enableCompression: boolean;
  flushIntervalMs: number;
  minSeverity: "info" | "warning" | "critical";
  categories?: (
  | "authorization"
  | "system"
  | "configuration"
  | "security"
  | "authentication"
  | "tool_invocation"
  | "data_access"
  | "data_modification"
  )[];
  },
  storage?: IAuditStorage,
  logger?: ILogger,
  ): AuditLogger

  #### Parameters

  - config: {
    logDir: string;
    filePrefix: string;
    maxFileSizeBytes: number;
    maxFiles: number;
    enableHashChain: boolean;
    enableCompression: boolean;
    flushIntervalMs: number;
    minSeverity: "info" | "warning" | "critical";
    categories?: (
    | "authorization"
    | "system"
    | "configuration"
    | "security"
    | "authentication"
    | "tool_invocation"
    | "data_access"
    | "data_modification"
    )[];
    }
  - `Optional` storage: IAuditStorage
  - `Optional` logger: ILogger

  #### Returns AuditLogger

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:170

## Methods

### log

- log(
  input: {
  category:
  | "authorization"
  | "system"
  | "configuration"
  | "security"
  | "authentication"
  | "tool_invocation"
  | "data_access"
  | "data_modification";
  severity: "info"
  | "warning"
  | "critical";
  outcome: "error" | "success" | "failure" | "denied";
  action: string;
  description?: string;
  actor: {
  type: "system" | "user" | "external" | "agent";
  id: string;
  name?: string;
  ip?: string;
  userAgent?: string;
  };
  resource?: { type: string; id: string; name?: string; path?: string };
  requestId?: string;
  traceId?: string;
  sessionId?: string;
  toolName?: string;
  durationMs?: number;
  metadata?: Record<string, unknown>;
  policyName?: string;
  policyDecision?: string;
  violationType?: string;
  },
  ): void

  Log an audit event

  #### Parameters

  - input: {
    category:
    | "authorization"
    | "system"
    | "configuration"
    | "security"
    | "authentication"
    | "tool_invocation"
    | "data_access"
    | "data_modification";
    severity: "info"
    | "warning"
    | "critical";
    outcome: "error" | "success" | "failure" | "denied";
    action: string;
    description?: string;
    actor: {
    type: "system" | "user" | "external" | "agent";
    id: string;
    name?: string;
    ip?: string;
    userAgent?: string;
    };
    resource?: { type: string; id: string; name?: string; path?: string };
    requestId?: string;
    traceId?: string;
    sessionId?: string;
    toolName?: string;
    durationMs?: number;
    metadata?: Record<string, unknown>;
    policyName?: string;
    policyDecision?: string;
    violationType?: string;
    }

  #### Returns void

  Implementation of IAuditLogger.log

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:245

### logToolInvocation

- logToolInvocation(opts: ToolInvocationAuditOpts): void

  Log a tool invocation

  #### Parameters

  - opts: ToolInvocationAuditOpts

  #### Returns void

  Implementation of IAuditLogger.logToolInvocation

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:263

### logPolicyDecision

- logPolicyDecision(opts: PolicyDecisionAuditOpts): void

  Log a policy decision

  #### Parameters

  - opts: PolicyDecisionAuditOpts

  #### Returns void

  Implementation of IAuditLogger.logPolicyDecision

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:279

### logSecurityEvent

- logSecurityEvent(opts: SecurityEventAuditOpts): void

  Log a security event

  #### Parameters

  - opts: SecurityEventAuditOpts

  #### Returns void

  Implementation of IAuditLogger.logSecurityEvent

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:295

### logRateLimitViolation

- logRateLimitViolation(opts: RateLimitAuditOpts): void

  Log a rate limit violation

  #### Parameters

  - opts: RateLimitAuditOpts

  #### Returns void

  Implementation of IAuditLogger.logRateLimitViolation

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:309

### logSystemStartup

- logSystemStartup(metadata?: Record<string, unknown>): void

  Log system startup event

  #### Parameters

  - `Optional` metadata: Record<string, unknown>

  #### Returns void

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:325

### logSystemShutdown

- logSystemShutdown(metadata?: Record<string, unknown>): void

  Log system shutdown event

  #### Parameters

  - `Optional` metadata: Record<string, unknown>

  #### Returns void

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:338

### flush

- flush(): Promise<void>

  Flush pending events

  #### Returns Promise<void>

  Implementation of IAuditLogger.flush

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:359

### close

- close(): Promise<void>

  Close the logger

  #### Returns Promise<void>

  Implementation of IAuditLogger.close

  - Defined in packages/nexus-agents/src/audit/audit-logger.ts:364