@livy/group-handler
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

@livy/group-handler

This Livy handler forwards log records to multiple other handlers. This is mostly useful in places where you can pass just one handler but want multiple ones to be executed (e.g. in a restrain handler).

Combine this with a filter handler to build powerful conditional cascades.


Synchronous logger support: yes

Runtime: Node.js and browsers


Basic Example

const { GroupHandler } = require('@livy/group-handler')
const { FileHandler } = require('@livy/file-handler')
const { ConsoleHandler } = require('@livy/console-handler')

// Create a compound handler which logs to a file and to the terminal
const handler = new GroupHandler([
  new FileHandler('logs.txt'),
  new ConsoleHandler()
])

Installation

Install it via npm:

npm install @livy/group-handler

Options

The first argument to this handler's constructor is an array (or any other iterable) of handlers to group.

An object of options can be passed to the constructor as the second argument.

The following options are available:

bubble

Type: boolean

Default: true

Description: Controls whether records handled by this handler should bubble up to other handlers.

See also: Bubbling

sequential

Type: boolean

Default: false

Description: Whether handlers must be executed sequentially instead of in parallel. This has an effect only in async mode.

Public API

bubble

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the bubble option.

See also: Bubbling

close()

This handler implements the ClosableHandlerInterface and does internal cleanup work. When closed, it also closes all contained closable handlers.

You usually don't want to call this method manually. It is done automatically when a Node.js process exits / a browser page is closed.

formatter (write-only)

Set the formatter of all contained (formattable) handlers.

processors

This handler supports processors by implementing the ProcessableHandlerInterface.

reset()

This handler implements the ResettableInterface. Resetting it resets all attached processors and all contained resettable handlers.

You usually don't want to call this method manually on an individual handler. Consider calling it on the logger instead.

Package Sidebar

Install

npm i @livy/group-handler

Weekly Downloads

15

Version

1.0.4

License

MIT

Unpacked Size

16.2 kB

Total Files

6

Last publish

Collaborators

  • loilo