Creates a new HTTPWorkerTransport instance.
Transport configuration
ProtectedclosingFlag to track if transport is currently closing.
Whether this transport is currently active and processing logs. Can be toggled at runtime to enable/disable specific transports.
Protected Optional ReadonlyexcludeTags that exclude logs from being processed.
Protected Optional ReadonlyfilterCustom filter function for advanced filtering.
Protected ReadonlyformatOutput format for this transport.
Protected Optional ReadonlyformatterCustom formatter function.
ProtectedinitializedFlag to track if transport has been initialized.
Protected ReadonlylevelMinimum log level for this transport.
Protected Optional ReadonlylevelsSpecific levels this transport handles (if specified).
ReadonlynameUnique identifier for this transport instance. Used for managing multiple transports and debugging.
Protected ReadonlyoptionsTransport configuration options.
Protected ReadonlysilentWhether to suppress errors from this transport.
ProtectedstatsStatistics tracking for this transport.
Protected Optional ReadonlytagsTags that must be present for logs to be processed.
Protected ReadonlytimeoutOperation timeout in milliseconds.
Disable the transport.
ProtecteddoProtectedCloses the transport and terminates the worker.
Ensures all buffered logs are sent before shutting down.
Resolves when fully closed
ProtecteddoProtectedInitializes the transport.
Waits for the worker to be ready before returning.
Resolves when initialized
ProtecteddoProtectedLogs an entry by passing it to the worker thread.
This method is non-blocking and returns immediately. The entry is passed to the worker using structured cloning, which is efficient for passing objects between threads.
The log entry to send
Protected OptionaldoProtectedOptional method for transport-specific batch logging. Subclasses can implement this for efficient batch processing.
Array of log entries to process
Resolves when all logs have been processed
Synchronously calls each of the listeners registered for the event namedeventName, in the order they were registered, passing the supplied arguments
to each.
Returns true if the event had listeners, false otherwise.
import EventEmitter from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
Enable the transport.
Flushes the worker's batch immediately.
Forces the worker to send any buffered logs immediately, regardless of batch size or timer.
Resolves when flush completes
ProtectedformatProtectedFormat a log entry according to the configured format.
The log entry to format
Formatted log entry
ProtectedformatProtectedFormat a log entry as plain text.
The log entry to format
Plain text formatted log entry
ProtectedgenerateProtectedGenerate a unique ID for tracking purposes.
A unique identifier
Get the transport name.
ProtectedhandleProtectedHandle errors according to the transport's configuration.
The error that occurred
Optionalentry: LogEntryThe log entry that caused the error (if applicable)
Check if the transport is currently enabled.
True if transport is enabled
Check if transport is healthy.
True if transport is healthy
ProtectedisProtectedCheck if a log level is enabled based on minimum level.
The level to check
True if the level is enabled
Log a single entry.
The log entry to process
Resolves when the log has been processed
Log multiple entries at once.
Array of log entries to process
Resolves when all logs have been processed
Alias for emitter.removeListener().
Implement EventEmitter methods explicitly for ITransport interface.
Reset transport statistics.
Check if this transport should handle a given log entry.
The log entry to check
True if the entry should be logged by this transport
ProtectedshouldProtectedWhether this transport should rethrow errors encountered during log operations. Network-based transports typically want propagation so callers/tests can assert failures. Base transports default to swallowing errors after emitting events and updating stats.
Check if transport supports batching.
True if batching is supported
Protectedwith
HTTP transport that uses a worker thread for all network operations.
This transport ensures zero blocking of the main thread by delegating all CPU and I/O intensive operations to a dedicated worker thread. The worker handles batching, compression, serialization, and HTTP requests.
HTTPWorkerTransport
Example: Basic Usage
Example: With Authentication
Example: With Circuit Breaker