@willow-dls/core
    Preparing search index...

    Class FileLogger

    A logger implementation that outputs a human-readable log file using the NodeJS stream API. This implementation is useful for writing out circuit executions to a file so that they can be debugged offline after the execution, as it is fairly normal for large circuits to produce large amount of log output.

    This logger requires a file name or write stream, and should be closed properly with close when circuit execution is complete.

    Hierarchy (View Summary)

    Index

    Constructors

    • Construct a new file logger, outputting to the given file or stream.

      Parameters

      • file: string | WriteStream

        The file path or a write stream to write log output to. Note that the file will be overwritten if it exists, not appended to.

      Returns FileLogger

    Methods

    • Close the log file, making sure all writes get flushed to the disk.

      Returns Promise<void>

      A promise that is fulfilled when all writes are complete.

    • Log a message to this logger. This method should normally not be used by most code, instead it is called by CircuitLoggable.log.

      Parameters

      • level: LogLevel

        The log level at which the message should be logged.

      • subsystem: string

        The subsystem for which the message is being logged.

      • msg: string

        The message to be logged.

      • Optionaldata: any

        Any additional data which should be logged but isn't necessarily fit for being embedded in the message.

      Returns void

    • This abstract function is to be implemented by loggers. It sinks the provided log message to whatever the log output is, be it a database, syslog, file, etc.

      Parameters

      • count: number

        A counter which increments up for each message that is logged. This can be used to ensure that messages are ordered correctly, or displayed in the final output somehow.

      • timestamp: Date

        The exact timestamp at which the log message was generated.

      • level: LogLevel

        The log level that the message is being logged at. Note that this function does not need to check the log level to filter out messages; messages will not be passed to this function in the first place if it shouldn't be logged due to the log level being too high.

      • subsystem: string

        The subsystem from which the log message came.

      • msg: string

        The log message.

      • Optionaldata: any

        Any additional data associated with the message but not explicitly a part of it.

      Returns void

    • Set the log level for this logger. Note that this can be called at any point, and when it is called, it does not do anything with previous messages, but it takes effect immediately when future messages are logged.

      Parameters

      • level: LogLevel

        The log level below which no messages will be output to this logger. All messages at or above this level will be logged.

      Returns CircuitLogger

      The current instance of CircuitLogger, for method chaining.

    • CircuitLoggables are assigned a "subsystem" ID which identifies it uniquely as something that logs messages. These subsystem strings can be used to filter out logs, which is exactly what this function does. It allows you to specify which subsystems you want to be logged and which subsystems you want to ignore.

      Parameters

      • ...subsystems: RegExp[]

        An array of regular expressions which a CircuitLoggable's subsystem ID must match in order for it to be logged. Note that only only one regular expression needs to be matched; as soon as a match is found, the message will be logged if the log level allows it. This allows you to log multiple subsystems without having to specify complex regular expressions; just specify a regular expression for each subsystem you want to match in whatever way makes sense to you.

      Returns CircuitLogger

      The current instanceof CircuitLogger, for method chaining.