open-index/open-npm huggingface dataset:
npm package: @livy/ansi-line-formatter
Description: Formats Livy log records as single lines with terminal highlighting
Author: loilo
Latest version: 1.0.3

# `@livy/ansi-line-formatter`

This [Livy](../../README.md#readme) formatter formats log records as single lines with terminal highlighting.

## Basic Example

```js
const { FileHandler } = require('@livy/file-handler')
const { AnsiLineFormatter } = require('@livy/ansi-line-formatter')

const handler = new FileHandler('logs.txt', {
  formatter: new AnsiLineFormatter()
})
```

## Installation

Install it via npm:

```bash
npm install @livy/ansi-line-formatter
```

## Options

An object of options can be passed to this formatter's constructor.

The following options are available:

### `decorated`

**Type:** `boolean | undefined`

**Default:** `undefined`

**Description:** Whether records should be highlighted with ANSI escape sequences. If this option is not provided (or explicitly set to `undefined`), color support will be detected automatically.

### `ignoreEmptyContext`

**Type:** `boolean`

**Default:** `false`

**Description:** Whether to omit empty context objects (only if extra is empty as well).

### `ignoreEmptyExtra`

**Type:** `boolean`

**Default:** `true`

**Description:** Whether to omit empty `extra` objects.

### `include`

**Type:** [`Partial<IncludedRecordProperties>`](../util/README.md#includedrecordproperties)

**Default:** `{}`

**Description:** Which log record properties to include in the output. The passed object is merged into the following default:

```js
{
  datetime: true,
  channel: false,
  level: true,
  severity: false,
  message: true,
  context: true,
  extra: true
}
```

## Public API

### `decorated`

Whether records should be highlighted with ANSI escape sequences. Initially set through the `decorated` option.

### `ignoreEmptyContext`

Whether to omit empty context objects (only if extra is empty as well). Initially set through the `ignoreEmptyContext` option.

### `ignoreEmptyExtra`

Whether to omit empty `extra` objects. Initially set through the `ignoreEmptyExtra` option.

### `include`

Which log record properties to include in the output. Initially set through the `include` option.
npm package: @livy/array-handler
Description: Stores Livy log records in an array
Author: loilo
Latest version: 1.0.4

# `@livy/array-handler`

This [Livy](../../README.md#readme) handler stores all log records it receives in an array which can then be read. This is mostly useful for debugging.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) yes

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { ArrayHandler } = require('@livy/array-handler')

const handler = new ArrayHandler()

// ...use handler in a logger...

// Print all records the handler received
console.log(handler.records)
```

## Installation

Install it via npm:

```bash
npm install @livy/array-handler
```

## Options

An object of options can be passed to the handler constructor as the first 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](../../README.md#bubbling)

### `level`

**Type:** [`LogLevel`](../contracts/README.md#loglevel)

**Default:** `'debug'`

**Description:** Controls which log records should be handled based on their [log level](../../README.md#log-levels).

## Public API

### `bubble`

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the [`bubble`](#bubble) option.

> See also: [Bubbling](../../README.md#bubbling)

### `level`

The minimum [log level](../../README.md#log-levels) of a log record to be considered by this handler. Initially set through the [`level`](#level) option.

### `records` (read-only)

The `records` property exposes all log records stored inside the `ArrayHandler`.

### `processors`

This handler supports [processors](../../README.md#processors) by implementing the [`ProcessableHandlerInterface`](../contracts/README.md#processablehandlerinterface).

### `reset()`

This handler implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting it clears its [records](#records-read-only) and resets all attached processors.

> You usually don't want to call this method manually on an individual handler. Consider calling it [on the logger](../logger/README.md#reset) instead.
npm package: @livy/browser-console-handler
Description: Writes Livy log records to a browser console
Author: loilo
Latest version: 1.0.4

# `@livy/browser-console-handler`

This [Livy](../../README.md#readme) handler writes log records to a browser console with highlighting.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) yes

**Runtime:** [Browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { BrowserConsoleHandler } = require('@livy/browser-console-handler')

const handler = new BrowserConsoleHandler()
```

## Installation

Install it via npm:

```bash
npm install @livy/browser-console-handler
```

## Options

An object of options can be passed to the handler constructor as the first 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](../../README.md#bubbling)

### `console`

**Type:** `Console`

**Default:** [the global `console` object](https://developer.mozilla.org/en-US/docs/Web/API/Console)

**Description:** The console object to use for logging

### `timestamps`

**Type:** `boolean`

**Default:** `false`

**Description:** Whether to include timestamps in the output

### `useNativeDebug`

**Type:** `boolean`

**Default:** `false`

**Description:** Whether to use the browser's built-in console.debug() for the "debug" level, which is only visible in the dev tools when explicitly configured so

### `level`

**Type:** [`LogLevel`](../contracts/README.md#loglevel)

**Default:** `'debug'`

**Description:** Controls which log records should be handled based on their [log level](../../README.md#log-levels).

## Public API

### `bubble`

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the [`bubble`](#bubble) option.

> See also: [Bubbling](../../README.md#bubbling)

### `level`

The minimum [log level](../../README.md#log-levels) of a log record to be considered by this handler. Initially set through the [`level`](#level) option.

### `processors`

This handler supports [processors](../../README.md#processors) by implementing the [`ProcessableHandlerInterface`](../contracts/README.md#processablehandlerinterface).

### `reset()`

This handler implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting it resets all attached processors.

> You usually don't want to call this method manually on an individual handler. Consider calling it [on the logger](../logger/README.md#reset) instead.
npm package: @livy/console-formatter
Description: Description of console-formatter
Author: loilo
Latest version: 1.0.3

# `@livy/console-formatter`

This [Livy](../../README.md#readme) formatter formats log records with highlighting for terminals in a human-readable way.

## Basic Example

```js
const { FileHandler } = require('@livy/file-handler')
const { ConsoleFormatter } = require('@livy/console-formatter')

const handler = new FileHandler('logs.txt', {
  formatter: new ConsoleFormatter()
})
```

## Installation

Install it via npm:

```bash
npm install @livy/console-formatter
```

## Options

An object of options can be passed to this formatter's constructor.

The following options are available:

### `decorated`

**Type:** `boolean | undefined`

**Default:** `undefined`

**Description:** Whether records should be highlighted with ANSI escape sequences. If this option is not provided (or explicitly set to `undefined`), color support will be detected automatically.

### `ignoreEmptyContext`

**Type:** `boolean`

**Default:** `false`

**Description:** Whether to omit empty context objects (only if extra is empty as well).

### `ignoreEmptyExtra`

**Type:** `boolean`

**Default:** `true`

**Description:** Whether to omit empty `extra` objects.

### `include`

**Type:** [`Partial<IncludedRecordProperties>`](../util/README.md#includedrecordproperties)

**Default:** `{}`

**Description:** Which log record properties to include in the output. The passed object is merged into the following default:

```js
{
  datetime: true,
  channel: false,
  level: true,
  severity: false,
  message: true,
  context: true,
  extra: true
}
```

## Public API

### `decorated`

Whether records should be highlighted with ANSI escape sequences. Initially set through the `decorated` option.

### `ignoreEmptyContext`

Whether to omit empty context objects (only if extra is empty as well). Initially set through the `ignoreEmptyContext` option.

### `ignoreEmptyExtra`

Whether to omit empty `extra` objects. Initially set through the `ignoreEmptyExtra` option.

### `include`

Which log record properties to include in the output. Initially set through the `include` option.
npm package: @livy/console-handler
Description: Writes Livy log records to the terminal
Author: loilo
Latest version: 1.0.3

# `@livy/console-handler`

This [Livy](../../README.md#readme) handler writes log records to the terminal.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) yes

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers) (although in browsers, you probably want [`@livy/browser-console-handler`](../browser-console-handler/README.md#readme))

---

## Basic Example

```js
const { ConsoleHandler } = require('@livy/console-handler')

const handler = new ConsoleHandler()
```

## Installation

Install it via npm:

```bash
npm install @livy/console-handler
```

## Options

An object of options can be passed to the handler constructor as the first 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](../../README.md#bubbling)

### `console`

**Type:** [`Console`](https://nodejs.org/api/console.html#console_class_console)

**Default:** [the global `console` object](https://nodejs.org/api/console.html#console_console)

**Description:** The console object to use for logging

### `formatter`

**Type:** [`FormatterInterface`](../contracts/README.md#formatterinterface)

**Default:** [`new ConsoleFormatter()`](../console-formatter/README.md#readme)

**Description:** The formatter to use.

### `level`

**Type:** [`LogLevel`](../contracts/README.md#loglevel)

**Default:** `'debug'`

**Description:** Controls which log records should be handled based on their [log level](../../README.md#log-levels).

## Public API

### `bubble`

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the [`bubble`](#bubble) option.

> See also: [Bubbling](../../README.md#bubbling)

### `defaultFormatter` (read-only)

The formatter used by this handler if no [`formatter`](#formatter) option is set.

### `formatter`

This handler supports formatters by implementing the [`FormattableHandlerInterface`](../contracts/README.md#formattablehandlerinterface).

### `level`

The minimum [log level](../../README.md#log-levels) of a log record to be considered by this handler. Initially set through the [`level`](#level) option.

### `processors`

This handler supports [processors](../../README.md#processors) by implementing the [`ProcessableHandlerInterface`](../contracts/README.md#processablehandlerinterface).

### `reset()`

This handler implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting it resets all attached processors.

> You usually don't want to call this method manually on an individual handler. Consider calling it [on the logger](../logger/README.md#reset) instead.
npm package: @livy/csv-formatter
Description: Formats Livy log records as CSV lines
Author: loilo
Latest version: 1.0.4

# `@livy/csv-formatter`

This [Livy](../../README.md#readme) formatter formats log records as CSV lines.

## Basic Example

```js
const { FileHandler } = require('@livy/file-handler')
const { CsvFormatter } = require('@livy/csv-formatter')

const handler = new FileHandler('logs.csv', {
  formatter: new CsvFormatter()
})
```

## Installation

Install it via npm:

```bash
npm install @livy/csv-formatter
```

## Options

An object of options can be passed to this formatter's constructor.

The following options are available:

### `delimiter`

**Type:** `string`

**Default:** `','`

**Description:** The delimiter to separate columns.

### `enclosure`

**Type:** `string`

**Default:** `'"'`

**Description:** The string to enclose fields.

### `eol`

**Type:** `string`

**Default:** `'\r\n'`

**Description:** The line terminator string.

### `generateFields`

**Type:** `function`

**Default:** A generator which includes date/time (as ISO 8601 string), log level, message, and JSON-serialized context and extra objects.

**Description:** A function to map each [log record](../../README.md#log-records) to an array of strings which represent the fields of each CSV line.
npm package: @livy/filter-handler
Description: Simple handler wrapper that filters records based on a test callback
Author: loilo
Latest version: 1.0.4

# `@livy/filter-handler`

This [Livy](../../README.md#readme) handler wraps another handler and filters [log records](../../README.md#log-records) passed to it based on a test callback.

Combine this with a [group handler](../group-handler/README.md#readme) to build powerful conditional cascades.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) yes

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { FilterHandler } = require('@livy/filter-handler')
const { FileHandler } = require('@livy/file-handler')

// Write logs appearing between 0am and 6am to a special file
const handler = new FilterHandler(
  new FileHandler('nightly-logs.txt'),
  record => record.datetime.hour >= 0 && record.datetime.hour <= 5
)
```

## Installation

Install it via npm:

```bash
npm install @livy/filter-handler
```

## Options

The first argument to this handler's constructor is a handler whose records to gate. The second argument is a callback that takes a [log record](../../README.md#log-records) and returns `true` or `false`, indicating whether or not that record should be forwarded to the wrapped handler.

An object of options can be passed to the handler constructor as the third 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](../../README.md#bubbling)

## Public API

### `bubble`

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the [`bubble`](#bubble) option.

> See also: [Bubbling](../../README.md#bubbling)

### `close()`

This handler implements the [`ClosableHandlerInterface`](../contracts/README.md#closablehandlerinterface) and does internal cleanup work. When closed, it also closes its wrapped handler (if applicable).

> 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.

### `processors`

This handler supports [processors](../../README.md#processors) by implementing the [`ProcessableHandlerInterface`](../contracts/README.md#processablehandlerinterface).

### `reset()`

This handler implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting it resets all attached processors and the wrapped handler (if applicable).

> You usually don't want to call this method manually on an individual handler. Consider calling it [on the logger](../logger/README.md#reset) instead.
npm package: @livy/hostname-processor
Description: Injects the running machine's hostname into a Livy log record
Author: loilo
Latest version: 1.0.4

# `@livy/hostname-processor`

This [Livy](../../README.md#readme) processor injects the running machine's hostname into a log record's `extra` object.

---

**Runtime:** Node.js

---

## Basic Example

```js
const { createLogger } = require('@livy/logger')
const { HostnameProcessor } = require('@livy/hostname-processor')

const logger = createLogger('app-logger', {
  processors: [HostnameProcessor]
})
```

## Installation

Install it via npm:

```bash
npm install @livy/hostname-processor
```
npm package: @livy/html-oneline-formatter
Description: Formats Livy log records as single-line HTML
Author: loilo
Latest version: 1.0.4

# `@livy/html-oneline-formatter`

This [Livy](../../README.md#readme) formatter formats log records as single-line HTML.

## Basic Example

```js
const { FileHandler } = require('@livy/file-handler')
const { HtmlOnelineFormatter } = require('@livy/html-oneline-formatter')

const handler = new FileHandler('logs.html', {
  formatter: new HtmlOnelineFormatter()
})
```

## Installation

Install it via npm:

```bash
npm install @livy/html-oneline-formatter
```

## Options

An object of options can be passed to this formatter's constructor.

The following options are available:

### `include`

**Type:** [`Partial<IncludedRecordProperties>`](../util/README.md#includedrecordproperties)

**Default:** `{}`

**Description:** Which log record properties to include in the output. The passed object is merged into the following default:

```js
{
  datetime: true,
  channel: false,
  level: true,
  severity: false,
  message: true,
  context: true,
  extra: true
}
```

### `theme`

**Type:** [`HtmlFormatterThemeInterface`](src/themes/html-formatter-theme-interface.ts)

**Default:** `{}`

**Description:** The color theme to use. A couple of included themes can be found [in the themes folder](src/themes).

### `wrap`

**Type:** [`HtmlFormatterThemeInterface`](src/themes/html-formatter-theme-interface.ts)

**Default:** `false`

**Description:** Whether to allow lines to wrap when they're too long for the display.

## Public API

### `include`

Which log record properties to include in the output. Initially set through the `include` option.

### `theme`

The color theme to use. Initially set through the `theme` option.

### `wrap`

Whether to allow lines to wrap when they're too long for the display. Initially set through the `wrap` option.
npm package: @livy/html-pretty-formatter
Description: Description of html-pretty-formatter
Author: loilo
Latest version: 1.0.4

# `@livy/html-pretty-formatter`

This [Livy](../../README.md#readme) formatter formats log records as extensive HTML.

## Basic Example

```js
const { FileHandler } = require('@livy/file-handler')
const { HtmlPrettyFormatter } = require('@livy/html-pretty-formatter')

const handler = new FileHandler('logs.html', {
  formatter: new HtmlPrettyFormatter()
})
```

## Installation

Install it via npm:

```bash
npm install @livy/html-pretty-formatter
```
npm package: @livy/json-formatter
Description: Serializes Livy log records as JSON
Author: loilo
Latest version: 1.0.4

# `@livy/json-formatter`

This [Livy](../../README.md#readme) formatter formats log records as one-line JSON objects.

## Basic Example

```js
const { FileHandler } = require('@livy/file-handler')
const { JsonFormatter } = require('@livy/json-formatter')

const handler = new FileHandler('logs.txt', {
  formatter: new JsonFormatter()
})
```

## Installation

Install it via npm:

```bash
npm install @livy/json-formatter
```

## Options

An object of options can be passed to this formatter's constructor.

The following options are available:

### `include`

**Type:** [`Partial<IncludedRecordProperties>`](../util/README.md#includedrecordproperties)

**Default:** `{}`

**Description:** Which log record properties to include in the output. The passed object is merged into the following default:

```js
{
  datetime: true,
  channel: true,
  level: true,
  severity: true,
  message: true,
  context: true,
  extra: true
}
```

### `batchMode`

**Type:** `JsonFormatter.BATCH_MODE_NEWLINES | JsonFormatter.BATCH_MODE_JSON`

**Default:** `JsonFormatter.BATCH_MODE_NEWLINES`

**Description:** How to store batched logs. `BATCH_MODE_NEWLINES` will just put out newline-delimited JSON objects, as if log records came in sequentially. `BATCH_MODE_JSON` wraps batched records in an array and outputs that.

## Public API

### `batchMode`

How batched records are formatted. Initially set through the `batchMode` option.

### `include`

Which log record properties to include in the output. Initially set through the `include` option.
npm package: @livy/level-filter-handler
Description: Simple handler wrapper that filters records based on a lower/upper level bound
Author: loilo
Latest version: 1.0.3

# `@livy/level-filter-handler`

This [Livy](../../README.md#readme) handler wraps another handler and filters records based on a lower/upper level bound.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) yes

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { LevelFilterHandler } = require('@livy/level-filter-handler')
const { FileHandler } = require('@livy/file-handler')

const handler = new LevelFilterHandler(
  new FileHandler('semi-serious-logs.txt'),
  { minLevel: 'notice', maxLevel: 'warning' }
)
```

## Installation

Install it via npm:

```bash
npm install @livy/level-filter-handler
```

## Options

The first argument to this handler's constructor is a handler whose records to gate.

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](../../README.md#bubbling)

### `minLevel`

**Type:** [`LogLevel`](../contracts/README.md#loglevel)

**Default:** `'debug'`

**Description:** The minimum activation level for the wrapped handler

### `maxLevel`

**Type:** [`LogLevel`](../contracts/README.md#loglevel)

**Default:** `'debug'`

**Description:** The maximum activation level for the wrapped handler

## Public API

### `bubble`

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the [`bubble`](#bubble) option.

> See also: [Bubbling](../../README.md#bubbling)

### `close()`

This handler implements the [`ClosableHandlerInterface`](../contracts/README.md#closablehandlerinterface) and does internal cleanup work. When closed, it also closes its wrapped handler (if applicable).

> 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.

### `getAcceptedLevels()`

Get an array of accepted log levels.

### `processors`

This handler supports [processors](../../README.md#processors) by implementing the [`ProcessableHandlerInterface`](../contracts/README.md#processablehandlerinterface).

### `reset()`

This handler implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting it resets all attached processors and the wrapped handler (if applicable).

> You usually don't want to call this method manually on an individual handler. Consider calling it [on the logger](../logger/README.md#reset) instead.

### `setAcceptedLevels(minLevel, maxLevel)`

Set the range of accepted log levels.
npm package: @livy/line-formatter
Description: Formats Livy log records as single lines
Author: loilo
Latest version: 1.0.4

# `@livy/line-formatter`

This [Livy](../../README.md#readme) formatter formats log records as single lines.

## Basic Example

```js
const { FileHandler } = require('@livy/file-handler')
const { LineFormatter } = require('@livy/line-formatter')

const handler = new FileHandler('logs.txt', {
  formatter: new LineFormatter()
})
```

## Installation

Install it via npm:

```bash
npm install @livy/line-formatter
```

## Options

An object of options can be passed to this formatter's constructor.

The following options are available:

### `ignoreEmptyContext`

**Type:** `boolean`

**Default:** `false`

**Description:** Whether to omit empty context objects (only if extra is empty as well).

### `ignoreEmptyExtra`

**Type:** `boolean`

**Default:** `true`

**Description:** Whether to omit empty `extra` objects.

### `include`

**Type:** [`Partial<IncludedRecordProperties>`](../util/README.md#includedrecordproperties)

**Default:** `{}`

**Description:** Which log record properties to include in the output. The passed object is merged into the following default:

```js
{
  datetime: true,
  channel: false,
  level: true,
  severity: false,
  message: true,
  context: true,
  extra: true
}
```

## Public API

### `ignoreEmptyContext`

Whether to omit empty context objects (only if extra is empty as well). Initially set through the `ignoreEmptyContext` option.

### `ignoreEmptyExtra`

Whether to omit empty `extra` objects. Initially set through the `ignoreEmptyExtra` option.

### `include`

Which log record properties to include in the output. Initially set through the `include` option.
npm package: @livy/logger
Description: A Monolog-inspired logging library for Node.js
Author: loilo
Latest version: 1.0.6

# `@livy/logger`

The [Livy](../../README.md#readme) logger factory is at the heart of every logger, as it creates a new logger instance.

## Basic Example

```js
const { createLogger } = require('@livy/logger')

const logger = createLogger('app-logger')
```

## Installation

Install it via npm:

```bash
npm install @livy/logger
```

## Options

The `createLogger` function takes a mandatory channel name as its first parameter. A second argument may be provided with object of options:

### `autoClose`

**Type:** `boolean`

**Default:** `true`

**Description:** Whether to automatically run the logger's `close` method when the Node.js process exits / the browser page closes.

### `handlers`

**Type:** [`Iterable<HandlerInterface | SyncHandlerInterface>`](../contracts/README.md#handlerinterface)

**Default:** `[]`

**Description:** Handlers of the logger.

### `mode`

**Type:** `'sync' | 'async' | 'mixed'`

**Default:** `'mixed'`

**Description:** The [concurrency mode](../../README.md#synchronous-and-asynchronous-logging) of the logger.

### `processors`

**Type:** [`Iterable<ProcessorInterfaceOrFunction>`](../contracts/README.md#processorinterfaceprocessorfunction)

**Default:** `[]`

**Description:** Processors of the logger.

### `timezone`

**Type:** `string` (IANA name)

**Default:** The runtime's time zone, determined by the [`Intl`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API.

**Description:** The time zone the logger should use.

## Logging

Logs can be created with the `log()` method. It takes a [log level](../../README.md#log-levels), a message and an optional context object:

```js
logger.log('info', 'This is the logged message')
```

Note that the `log` method returns a Promise in [`async` mode](#mode), so it should be awaited to avoid unexpected failures:

```js
await logger.log('info', 'This is the logged message')
```

---

For each log level, there is a convenience method which allows omitting the level parameter:

```js
logger.debug('This is a debug message')
logger.info('This is an info message')
logger.notice('This is a notice message')
logger.warning('This is a warning message')
logger.error('This is an error message')
logger.alert('This is an alert message')
logger.critical('This is a critical message')
logger.emergency('This is an emergency message')
```

## Public API

### `reset()`

Resetting a logger will reset all its handlers and processors which implement the [`ResettableInterface`](../contracts/README.md#resettableinterface).

### `name` (read-only)

The logger's channel name.

### `withName(name)`

Clone the logger with a new name.

### `timezone` (read-only)

The logger's IANA time zone name.
npm package: @livy/memory-usage-processor
Description: Injects memory usage into a Livy log record
Author: loilo
Latest version: 1.0.4

# `@livy/memory-usage-processor`

This [Livy](../../README.md#readme) processor injects current memory usage into a log record's `extra` object.

---

**Runtime:** Node.js

---

## Basic Example

```js
const { createLogger } = require('@livy/logger')
const { MemoryUsageProcessor } = require('@livy/memory-usage-processor')

const logger = createLogger('app-logger', {
  processors: [new MemoryUsageProcessor()]
})
```

## Installation

Install it via npm:

```bash
npm install @livy/memory-usage-processor
```

## Options

The `MemoryUsageProcessor` constructor takes an optional boolean `humanReadable` parameter (which defaults to `true`). It formats memory usage in a human readable way. Turn it off to inject the raw number of bytes.
npm package: @livy/noop-handler
Description: Handles any Livy log records, but does nothing with them
Author: loilo
Latest version: 1.0.4

# `@livy/noop-handler`

This [Livy](../../README.md#readme) handler handles anything, but does nothing, and does not stop bubbling to the rest of the stack. This can be useful for testing.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) yes

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { NoopHandler } = require('@livy/noop-handler')

const handler = new NoopHandler()
```

## Installation

Install it via npm:

```bash
npm install @livy/noop-handler
```
npm package: @livy/null-handler
Description: Black hole for Livy log records
Author: loilo
Latest version: 1.0.4

# `@livy/null-handler`

This [Livy](../../README.md#readme) handler acts as a black hole. Any record it can handle will be thrown away. This can be used to put on top of an existing stack to override it temporarily.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) yes

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { NullHandler } = require('@livy/null-handler')

const handler = new NullHandler('error')
```

## Installation

Install it via npm:

```bash
npm install @livy/null-handler
```

## Options

This handler's constructor accepts an optional minimum [log level](../../README.md#log-levels) (defaulting to `'debug'`). All log records below that level will regularly bubble up the stack, everything else will be thrown away.
npm package: @livy/process-id-processor
Description: Injects the current process ID into a Livy log record
Author: loilo
Latest version: 1.0.4

# `@livy/process-id-processor`

This [Livy](../../README.md#readme) processor injects the current process ID into a log record's `extra` object.

---

**Runtime:** Node.js

---

## Basic Example

```js
const { createLogger } = require('@livy/logger')
const { ProcessIdProcessor } = require('@livy/process-id-processor')

const logger = createLogger('app-logger', {
  processors: [ProcessIdProcessor]
})
```

## Installation

Install it via npm:

```bash
npm install @livy/process-id-processor
```
npm package: @livy/socket.io-handler
Description: Sends Livy log records to a WebSocket server
Author: loilo
Latest version: 1.0.3

# `@livy/socket.io-handler`

This [Livy](../../README.md#readme) handler sends log records to a [Socket.IO](https://socket.io) server.

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) no

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { SocketIoHandler } = require('@livy/socket.io-handler')

const handler = new SocketIoHandler('wss://example.com/logs')
```

## Installation

Install it via npm:

```bash
npm install @livy/socket.io-handler
```

## Options

The first argument to this handler's constructor contains the Socket.IO endpoint to connect to.

An object of options can be passed 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](../../README.md#bubbling)

### `connection`

**Type:** `object`

**Default:** `{}`

**Description:** An object of Socket.IO client [initialization options](https://socket.io/docs/client-api/#io-url-options).

### `level`

**Type:** [`LogLevel`](../contracts/README.md#loglevel)

**Default:** `'debug'`

**Description:** Controls which log records should be handled based on their [log level](../../README.md#log-levels).

## Public API

### `bubble`

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the [`bubble`](#bubble) option.

> See also: [Bubbling](../../README.md#bubbling)

### `close()`

This handler implements the [`ClosableHandlerInterface`](../contracts/README.md#closablehandlerinterface). On cleanup, it closes the Socket.IO connection.

> 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.

### `level`

The minimum [log level](../../README.md#log-levels) of a log record to be considered by this handler. Initially set through the [`level`](#level) option.

### `processors`

This handler supports [processors](../../README.md#processors) by implementing the [`ProcessableHandlerInterface`](../contracts/README.md#processablehandlerinterface).

### `reset()`

This handler implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting it resets all attached processors.

> You usually don't want to call this method manually on an individual handler. Consider calling it [on the logger](../logger/README.md#reset) instead.
npm package: @livy/stream-handler
Description: Writes Livy log records to a Node.js stream
Author: loilo
Latest version: 1.0.3

# `@livy/stream-handler`

This [Livy](../../README.md#readme) handler writes log records to a [Node.js stream](https://nodejs.org/api/stream.html#stream_writable_streams).

---

[**Synchronous logger support:**](../../README.md#synchronous-and-asynchronous-logging) no

**Runtime:** Node.js

---

## Basic Example

```js
const { StreamHandler } = require('@livy/stream-handler')

const handler = new StreamHandler('wss://example.com/logs')
```

## Installation

Install it via npm:

```bash
npm install @livy/stream-handler
```

## Options

The first argument to this handler's constructor is a [writable Node.js stream](https://nodejs.org/api/stream.html#stream_writable_streams) to write log records to.

An object of options can be passed 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](../../README.md#bubbling)

### `formatter`

**Type:** [`FormatterInterface`](../contracts/README.md#formatterinterface)

**Default:** [`new LineFormatter()`](../line-formatter/README.md#readme)

**Description:** The formatter to use.

### `level`

**Type:** [`LogLevel`](../contracts/README.md#loglevel)

**Default:** `'debug'`

**Description:** Controls which log records should be handled based on their [log level](../../README.md#log-levels).

## Public API

### `bubble`

Controls whether records handled by this handler should bubble up to other handlers. Initially set through the [`bubble`](#bubble) option.

> See also: [Bubbling](../../README.md#bubbling)

### `defaultFormatter`

The formatter used by this handler if no [`formatter`](#formatter) option is set.

### `formatter`

This handler supports formatters by implementing the [`FormattableHandlerInterface`](../contracts/README.md#formattablehandlerinterface).

### `level`

The minimum [log level](../../README.md#log-levels) of a log record to be considered by this handler. Initially set through the [`level`](#level) option.

### `processors`

This handler supports [processors](../../README.md#processors) by implementing the [`ProcessableHandlerInterface`](../contracts/README.md#processablehandlerinterface).

### `reset()`

This handler implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting it resets all attached processors.

> You usually don't want to call this method manually on an individual handler. Consider calling it [on the logger](../logger/README.md#reset) instead.
npm package: @livy/tags-processor
Description: Adds tags to a Livy log record
Author: loilo
Latest version: 1.0.4

# `@livy/tag-processor`

This [Livy](../../README.md#readme) processor adds predefined tags to a log record's `extra` object.

---

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { createLogger } = require('@livy/logger')
const { TagsProcessor } = require('@livy/tag-processor')

const logger = createLogger('app-logger', {
  processors: [
    // Adds `tags: ['demo', 'docs']` to the `extra` object
    new TagsProcessor('demo', 'docs')
  ]
})
```

## Installation

Install it via npm:

```bash
npm install @livy/tag-processor
```

## Options

The `TagsProcessor` constructor takes an arbitrary number of strings to inject as tags.

## Public API

### `addTags(...tags)`

Add tags to the processor. Duplicates will be removed.

### `setTags(...tags)`

Set the processor's tags.
npm package: @livy/uid-processor
Description: Adds a unique identifier to Livy log records
Author: loilo
Latest version: 1.0.4

# `@livy/uid-processor`

This [Livy](../../README.md#readme) processor adds a unique identifier to a log record's `extra` object. The identifier is _not_ unique per-record but created with the `UidProcessor` instance.

---

**Runtime:** Node.js and [browsers](../../README.md#usage-in-browsers)

---

## Basic Example

```js
const { createLogger } = require('@livy/logger')
const { UidProcessor } = require('@livy/uid-processor')

const logger = createLogger('app-logger', {
  processors: [new UidProcessor()]
})
```

## Installation

Install it via npm:

```bash
npm install @livy/uid-processor
```

## Options

The `UidProcessor` constructor takes the length of the unique identifier (in bytes, the actual identifier will be a hex string of double the length), defaulting to `7`.

## Public API

### `reset()`

This processor implements the [`ResettableInterface`](../contracts/README.md#resettableinterface). Resetting will generate a new identifier.

> You usually don't want to call this method manually on an individual processor. Consider calling it [on the logger](../logger/README.md#reset) instead.

### `uid`

Get the generated unique identifier.
npm package: @livyn/type
Description: A comprehensive JavaScript/Node.js utility library for type detection and type conversion.
Author: Dimas Fajar
Latest version: 1.0.0

![npm](https://img.shields.io/npm/v/@livyn/type)
![License](https://img.shields.io/npm/l/@livyn/type)
![ESM](https://img.shields.io/badge/javascript-ESM-orange)
![Node](https://img.shields.io/badge/node-%3E=18.0.0-green)

# @livyn/type

A comprehensive JavaScript/Node.js utility library for **type detection** and **type conversion** — made for simplicity, performance, and accuracy.

---

## ✨ Key Features

- 🧩 **Type Detection** – Detect the precise type of any value (`dataType`)
- 🔐 **Type Assertion** – Assert value types with optional negation (`assertType`)
- ✅ **Type Checking** – Check if a value matches a specific type (`isType`)
- 🔄 **Type Conversion** – Convert values to a specific type or all types (`toType`)
- 💡 **Supports:**
  - Primitives: `string`, `number`, `boolean`, `bigint`, `symbol`, `null`, `undefined`
  - Built-in objects: `Array`, `Date`, `RegExp`, `Map`, `Set`, `Promise`
  - Functions: regular, async, generator
  - Custom classes

---

## 📦 Installation

```bash
npm install @livyn/type
```
---

## 📘 Usage

### Importing

```js
import typeUtils from '@livyn/type';

// or named imports
import { dataType, isType, toType, assertType } from '@livyn/type';
```

---

### `dataType`

Detects the precise type of a value.

```js
console.log(dataType(123));                  // "number"
console.log(dataType("hello"));              // "string"
console.log(dataType(null));                 // "null"
console.log(dataType([]));                   // "array"
console.log(dataType(async () => {}));       // "asyncfunction"
console.log(dataType(class User {}));        // "class"
```

---

### `isType`

Checks if a value matches an expected type.

```js
console.log(isType(123, "number"));          // true
console.log(isType("hello", "string"));      // true
console.log(isType([], "array"));            // true
console.log(isType(class User {}, "class")); // true
```

---

### `assertType`

Asserts that a value matches (or does not match) a type. Throws `TypeError` if invalid.

```js
assertType(123, "number");       // returns 123
assertType("hello", "!number");  // returns "hello"

try {
  assertType("abc", "!string");  // throws TypeError
} catch (e) {
  console.log(e.message);        // "Invalid type: expected not string, got string"
}
```

---

### `toType`

Converts a value to a specified type or all types.

```js
console.log(toType("123abc", "number")); // 123
console.log(toType("123abc", "bigint")); // 123n
console.log(toType("false", "boolean")); // false
console.log(toType({a:1,b:2}, "string")); // "{a: 1, b: 2}"

console.log(toType("abcd123")); // returns object with all type conversions
```

---

## Supported Types

- `number`, `bigint`, `boolean`, `string`, `array`, `date`, `object`, `regexp`

---

## 👤 Author

**[Dimas Fajar](https://github.com/fajardison)**

---

## ⚖️ License

This project is licensed under the **MIT License** – see the [LICENSE](https://raw.githubusercontent.com/fajardison/artiq-stylize/refs/heads/main/LICENSE) file for details.