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

paralogger

v0.2.1

Published

A customisable logger for node.js

Downloads

3

Readme

Paralogger

npm npm

Paralogger is a completely customisable logger built upon it's own standard. You seperate your logs into different scopes, filter through log levels, and ultimately decide how you display, store, or broadcast them.

Installation

Install paralogger using your favourite package manager.

# npm
npm i paralogger

# yarn
yarn add paralogger

Usage

Create a logger instance to begin working with paralogger, defining a scope or leaving it to the default (SYSTEM).

const logger = new Logger('CUSTOM')

Standard

A log is made up of 4 properties.

  • scope - The name of the logger instance
  • level - The level of the log
  • timestamp - The time the log was created
  • message - The text contents of the log

You assign the scope when you create your logger instance. You may have multiple logger instances, so this helps you keep track of a log's origins.

The level of a log details what the log is for. The supported log levels are.

  • fatal - Severe runtime errors that cause the application or subprocess to unexpectedly crash
  • error - A non-fatal runtime error or other unusual conditional events
  • warn - For use of deprecated items and important non-error events that should be looked at.
  • info - Used for basic system events like started or stopped
  • debug - Contains information useful for debugging issues with the application, such as internal state, etc.
  • trace - The most detailed logs, useful for logging things like network traffic, login attemps, etc.

Timestamps should be presented in UTC or local time depending on the requirements of the project. UTC is recommended where possible to avoid confusion for people in different zones to the deployment or for projects with deployments in multiple timezones.

Messages are a string, and should be single line when possible. You may wish to apply your own standard for certain logs, like REST API logs, etc.

Logging to the console can be added using the following steps.

  1. Import logToConsole from paralogger
  2. Call .on('log', logToConsole()) with your logger instance

This adds an event handler to log to the console. You can remove the colors by passing the colorful argument as false. This is the format that the logToConsole() handler uses.

YYYY-MM-DD HH:MM:SS {SCOPE} {LEVEL} {MESSAGE}

You can also create your own handlers and add them to any of the events. A handler will be passed a Log object containing the 4 properties mentioned above.

Contributing

Contributions are welcome. If you wish to add something to paralogger, please make an issue to discuss it first :)

License

Distributed under the MIT license.