Skip to main content

Class: JSONLogStream

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

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:32

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:33
throttleRatereadonlynumber1Optional throttling rate - only 1/throttleRate entries will be written. Default is 1 (no throttling).logging/json-log-stream.ts:34

Methods​

appendEntry()​

appendEntry(e): Promise<void>

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

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:69

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>