Skip to main content

Class: JSONLogStream

Defined in: logging/json-log-stream.ts:20

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

Implements

Constructors

Constructor

new JSONLogStream(path, throttleRate?): JSONLogStream

Defined in: logging/json-log-stream.ts:31

Creates a new JSONLogStream

Parameters

ParameterTypeDefault valueDescription
pathstringundefinedPath to the JSON log file
throttleRatenumber1Optional throttling rate - only 1/throttleRate entries will be written. Default is 1 (no throttling).

Returns

JSONLogStream

Properties

PropertyModifierTypeDefault valueDescriptionDefined in
pathreadonlystringundefinedPath to the JSON log filelogging/json-log-stream.ts:31
throttleRatereadonlynumber1Optional throttling rate - only 1/throttleRate entries will be written. Default is 1 (no throttling).logging/json-log-stream.ts:31

Methods

appendEntry()

appendEntry(e): Promise<void>

Defined in: logging/json-log-stream.ts:44

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

Parameters

ParameterTypeDescription
eNormalizedLogEntry<LogEntry>The normalized log entry to append

Returns

Promise<void>

Implementation of

LogStream.appendEntry


close()

close(): Promise<void>

Defined in: logging/json-log-stream.ts:63

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

Returns

Promise<void>