The LogBatch helper class to help with creating multiple logs without sending, and sending the created logs at a chosen point in time. Use in conjunction with Logger.startBatch() and Logger.sendBatch().

Hierarchy

  • LogBatch

Constructors

Properties

host: string = "127.0.0.1"
logBatch: Log[] = []
logger: null | Logger = null
port: string = "3002"
surround: number = 3

Methods

  • Adds a log to the current LogBatch.

    Type Parameters

    Parameters

    • message: T

      The message for the current log.

    • Optional surround: number

      The optional surrounding amount of code lines to include in the code snippet.

    Returns LogBatch

  • Adds a log to the current LogBatch that only sends if the condition resolves to true.

    Type Parameters

    Parameters

    • condition: (() => boolean)

      The condition function that determines whether the log gets sent to the remote.

        • (): boolean
        • Returns boolean

    • message: T

      The message for the current log.

    • Optional surround: number

      The optional surrounding amount of code lines to include in the code snippet.

    Returns LogBatch

  • Adds a log to the current LogBatch if the CODECTRL_DEBUG environment variable is present.

    Type Parameters

    Parameters

    • message: T

      The message for the current log.

    • Optional surround: number

      The optional surrounding amount of code lines to include in the code snippet.

    Returns LogBatch

  • Creates the final Logger that will be used to send the batch of logs created with the addLog, addLogIf and addLogWhenEnv functions.

    Returns Logger

  • Set the host for this batch of logs.

    Parameters

    • host: string

      This hostname/IP/domain of the remote CodeCTRL server.

    Returns LogBatch

  • Set the port for this batch of logs.

    Parameters

    • port: string

      The port of that the remote CodeCTRL server is listening on.

    Returns LogBatch

  • Set the surround for this batch of logs.

    Parameters

    • surround: number

      The amount of code lines to include in the code snippet surrounding the log line.

    Returns LogBatch

Generated using TypeDoc