A fast, flexible JSON logger.
The package.json has two configurations related to Node.js installations:
main
: points to the minified version compiled for v6.0.0 and above.module
: points to the src files. Module field details.The index.js points to the minified version compiled for v6.0.0 and above.
npm install --save perj
Use the dist files or bundle from src.
Type | Size | CDN |
---|---|---|
gzipped | https://unpkg.com/perj/dist/perj.min.js.gz | |
minified | https://unpkg.com/perj/dist/perj.min.js | |
full (source map) | https://unpkg.com/perj/dist/perj.js |
See Unpkg for fixed version options.
The following example adds ver
, name
, host
, pid
and file
top level property to the log output:
const Perj = require('perj')
// Customize the variables below as needed. They are not required.
const ver = 1
const name = 'QuickStart'
const host = require('os').hostname()
const pid = process.pid
const file = require('path').basename(module.filename, '.js')
const log = new Perj({ver, name, host, pid, file})
log.info('the quick brown fox jumps over the lazy dog')
/*
The following string is sent to standard out:
{"level":"info","lvl":30,"ver":1,"name":"QuickStart","host":"Dev","pid":233241,"file":"quick-start","time":1526102959677,"msg":"the quick brown fox jumps over the lazy dog","data":""}
*/
The following example adds ver
, name
, and host
top level property to the log entries:
const Perj = require('perj')
// Customize the variables below as needed. They are not required.
const ver = 1
const name = 'QuickStart'
const host = location.hostname
const log = new Perj({ver, name, host})
log.info('the quick brown fox jumps over the lazy dog')
/*
The following string is sent to the console:
{"level":"info","lvl":30,"ver":1,"name":"QuickStart","host":"http://Dev","time":1526103303019,"msg":"the quick brown fox jumps over the lazy dog","data":""}
*/
For full documentation see the Wiki.
I, Grant Carthew, am a technologist, trainer, and Dad from Queensland, Australia. I work on code in a number of personal projects and when the need arises I build my own packages.
This project exists because I was not happy with other logging packages.
Everything I do in open source is done in my own time and as a contribution to the open source community.
If you are using my projects and would like to thank me or support me, please click the Patreon link below.
See my other projects on NPM.
This project only exists because it is standing on the shoulders of GIANTS.
Special thanks to the guys working on pino being:
A lot of the inspiration for perj
came from the pino package.
Not to mention the other packages and resources used to help develop on the Node.js platform.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature