npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

perj

v4.0.2

Published

A fast, flexible JSON logger.

Downloads

14

Readme

perj

A fast, flexible JSON logger.

Maintainability File Size NPM Version 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.

| Type | Size | CDN | | ----------------- | ---------------------------------------------- | ------------------------------------------ | | gzipped | File Size | https://unpkg.com/perj/dist/perj.min.js.gz | | minified | File Size | https://unpkg.com/perj/dist/perj.min.js | | full (source map) | File Size | https://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:

import Perj from 'perj';
import os from 'os';
import path from 'path';

// Customize the variables below as needed. They are not required.
const ver = 1;
const name = 'QuickStart';
const host = os.hostname();
const pid = process.pid;
const file = path.basename(import.meta.url, '.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:

import Perj from "https://unpkg.com/perj/dist/perj.js"

// 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'm Grant Carthew, a technologist from Queensland, Australia, with a passion for coding. I delve into personal projects and develop custom solutions when the existing tools fall short.

This repository hosts my custom logging solution, created because I couldn't find a logging package that met my needs.

All my open-source work is crafted in my own time, as a contribution to the community that has supported me.

If my projects have been useful to you and you'd like to express your appreciation or support, please consider joining me on Patreon. Your support helps sustain and grow these initiatives!

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