File handler class for managing file operations

Hierarchy

  • EventEmitter
    • FileHandler

Constructors

Properties

Methods

Events

Constructors

Properties

name: string

Service name

Service setup options

rotationScheduled: boolean = false

Flag to indicate if a rotation is scheduled

stats: FileStats = ...

File stats

Methods

  • Appends data to the file store. This method uses the Limiter to ensure only one file operation is executed at a time (concurrency=1) and to retry the append operation if necessary

    Parameters

    • data: string

      The data to append to the file.

    Returns Promise<void>

    A promise that resolves when the append operation is complete.

  • Closes the current file stream.

    Returns Promise<void>

    A promise that resolves when the file stream is closed.

Events

  • Add a listener for the error event, emitted when there is an error in a file handler operation.

    Parameters

    • event: "error"

      error event

    • listener: (error: Crash) => void

      Error event listener

    Returns this

  • Add a listener for the rotate event, emitted when a file is rotated.

    Parameters

    • event: "rotate"

      error event

    • listener: (stats: FileStats) => void

      Error event listener

    Returns this

  • Add a listener for the resolve event, emitted when an operation is resolved.

    Parameters

    • event: "resolve"

      resolve event

    • listener: (stats: FileStats) => void

      Resolve event listener

    Returns this