@rollup/log
TypeScript icon, indicating that this package has built-in type declarations

0.1.0Β β€’Β PublicΒ β€’Β Published

@rollup-cabal/log

tests cover chat size

🌳

A logger that provides targeted log levels and display options.

Note: This module requires Node 8.11.0.

Install

Using npm:

$ npm install @rollup-cabal/log

Using yarn:

$ yarn add @rollup-cabal/log

Usage

import { logger } from '@rollup-cabal/log';

const log = logger()

log.info('batman');

//β†’ β“‘ batman

API

logger([options])

Each log instance is unique by default. To persist an instance and fetch it elsewhere, provide an id property on options.

options

Type: object

id

Type: string

A unique identifier for a log instance.

level

Type: string
Default: info
Values: trace debug info warn error

The minimum log level to display output for. Output for levels above the set level will be displayed. Log levels shown in Values above are in order of lowest to highest.

Setting a level of 'info' will display output for log.info, log.warn, and log.error. Setting a level of 'error' will display output only for log.error.

preface

Type: string

Text to display before each log message.

import { logger } from '@rollup-cabal/log';

const log = logger({ preface: 'β‹Š batcave ⋉' });

log.info('batman');

//β†’ β“‘ β‹Š batcave ⋉ batman
timestamp

Type: string
Default: boolean

Set to true to display a timestamp before each log message.

import { logger } from '@rollup-cabal/log';

const log = logger({ timestamp: true });

log.info('batman');

//β†’ [00:00:00] β“‘ batman
stderr

Type: Array[string]
Default: ['info', 'warn', 'error', 'pass', 'fail']

Defines the levels which output to stderr by default. This setting is useful for directing select loggers to output only specific levels to stderr while allowing other levels to output to stdout.

import { logger } from '@rollup-cabal/log';

const log = logger({ stderr: ['warn', 'error'] });

log.info('batman');

// stdout β†’ β“‘ batman

log.warn('riddler');

// stderr β†’ β“‘ riddler

Instance

.info(text: string)

Displays output to stderr prefaced with β“‘ colored blue. Akin to console.log.

.warn(text: string)

Displays output to stderr prefaced with β“‘ colored yellow.

.error(text: string)

Displays output to stderr prefaced with β“‘ colored red.

.debug(text: string)

Displays output to stdout prefaced with β“‘ colored magenta.

.trace(text: string)

Displays trace output akin to console.trace to stdout prefaced with β“‘ colored cyan.

.pass(text: string)

Displays output to stderr prefaced with β“‘ colored green. The output is persisted regardless of the set level.

.fail(text: string)

Displays output to stderr prefaced with β“‘ colored red. The output is persisted regardless of the set level.

Meta

CONTRIBUTING

LICENSE (MIT)

Dependencies (5)

Dev Dependencies (24)

Package Sidebar

Install

npm i @rollup/log

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

10.8 kB

Total Files

6

Last publish

Collaborators

  • guybedford
  • lukastaegert
  • rich_harris
  • shellscape