envtrace

0.0.2 • Public • Published

envtrace

all the convenience of xtrace + debug in a single package

  1. Let's say you want to be able to add logging a la debug and your application is called dope :
DEBUG=dope node my-file.js
  1. Use envtrace just like you would use debug:
// my-file.js
import { pipe } from 'ramda'
import { envtrace } from 'envtrace'

const ntrace = envtrace('dope')

const myFunction = pipe(
  ntrace('input'),
  x => x * 2,
  ntrace('output')
)
  1. Wanna use multiple loggers? That's easy:
// example-complex.js

const { pipe } = require('ramda')
const N = require('./envtrace')

const log = N.complextrace('example', [
  'info',
  'warn',
  'detail',
  'error'
])

const example = () => {
  pipe(
    log.info('input'),
    x => x * 2,
    log.warn('twice'),
    x => x * 3,
    log.detail('deets'),
    x => x * 4,
    log.error('nice'),
    x => x * 5,
    log.info('output')
  )(10)
}
example()

Then the above can be run with DEBUG=example:* node example-complex.js and it will print:

example:info input 10 +0ms
example:warn twice 20 +0ms
example:detail deets 60 +0ms
example:error nice 240 +0ms
example:info output 1200 +3ms

Dependencies (4)

Dev Dependencies (12)

Package Sidebar

Install

npm i envtrace

Weekly Downloads

11

Version

0.0.2

License

ISC

Unpacked Size

115 kB

Total Files

4

Last publish

Collaborators

  • brekk