Skip to main content

JSONLogStream

A LogStream implementation that writes log entries to a JSON file. Supports optional throttling to reduce the number of entries written.

Implements: LogStream

Constructor

new JSONLogStream(path: string, throttleRate: number)

Creates a new JSONLogStream

Methods

appendEntry()

appendEntry(e: NormalizedLogEntry<LogEntry>): Promise<void>

Appends a log entry to the JSON file, respecting the throttle rate

close()

close(): Promise<void>

Closes the JSON log file if it's open. This is handled automatically by the stream and there's no need to call it explicitly under normal operation.

You may want to call this explicitly when:

  • You need to ensure logs are flushed to disk immediately
  • You're shutting down the application and want to clean up resources
  • You want to release the file handle before the automatic timeout