envtrace
v0.0.2
Published
xtrace x debug
Downloads
141
Readme
envtrace
all the convenience of xtrace
+ debug
in a single package
- 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
- Use
envtrace
just like you would usedebug
:
// 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')
)
- 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