Class LogFile<T>

Represents a log file manager that appends log entries to a file. It does not ensure extremely precise ordering of log entries' timestamps if used asynchronously. It logs them as they are received.

Type Parameters

  • T

Hierarchy

  • LogFile

Constructors

Properties

filepath: string

The path to the log file.

Methods

  • Appends a log entry to the log file.

    Parameters

    • data: T

      The data to be logged.

    • time: number = ...

      The timestamp of the log entry. Defaults to the current time.

    Returns Promise<void>

    A promise that resolves when the log entry is appended.

  • Returns an async generator that yields the entries (timestamp and value) of log entries in the log file.

    Returns AsyncGenerator<[number, T], any, unknown>

    Yields

    The entries (timestamp and value) of log entries.

  • Returns an async generator that yields the timestamps of log entries in the log file.

    Returns AsyncGenerator<number, any, unknown>

    Yields

    The timestamps of log entries.

  • Reads the log entire file and returns an array of log entries, sorted by timestamp in descending order.

    Returns [number, T][]

    An array of log entries, sorted by timestamp in descending order.

  • Returns an async generator that yields the values of log entries in the log file.

    Returns AsyncGenerator<T, any, unknown>

    Yields

    The values of log entries.

Generated using TypeDoc