3.2.0 • Published 6 years ago

perj v3.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

perj

A fast, flexible JSON logger.

Maintainability Test Coverage Build Status File Size NPM Version js-standard-style NSP Status Patreon Donation Twitter

perj

Installing

Node.js

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

Browser

Use the dist files or bundle from src.

TypeSizeCDN
gzippedFile Sizehttps://unpkg.com/perj/dist/perj.min.js.gz
minifiedFile Sizehttps://unpkg.com/perj/dist/perj.min.js
full (source map)File Sizehttps://unpkg.com/perj/dist/perj.js

See Unpkg for fixed version options.

Goals

  • Designed to be integrated (DIY) ✔️
  • Cross platform (Node.js and Browser) ✔️
  • Flexible log and additional property options ✔️
  • Fast ✔️

Features

  • No dependencies.
  • Flexible API (change almost everything).
  • Flexible log methods:
    • Log items can be any number in any order of any type.
  • The first string is nested under the 'msg' key:
    • First string includes a string argument or an Error message.
    • Additional string arguments are nested under the data key.
  • Objects are nested under the 'data' key as an object or array of objects.
  • Repeated string top level properties become hierarchical.
  • Examples to get you started.

Quick Start

Node.js Usage

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":""}

*/

Browser Usage

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":""}

*/

Documentation

For full documentation see the Wiki.

About the Owner

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.

Patreon Donation

See my other projects on NPM.

Credit

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.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D
3.2.0

6 years ago

3.1.0

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago