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

jsout

v1.0.5

Published

A very small, simple, opinionated, and structured logger for Typescript and Javascript.

Downloads

238

Readme

jsout

build status semantic-release Conventional Commits SemVer

A DevOps friendly, small, and simple logger for Typescript/Javascript projects.

Structured Logs 🔒

  • Supports both human-readable CLI output and JSON output for log aggregation into services like sumologic, New Relic, DataDog, etc.

Defensive & Devops Friendly 🛡

  • Logs are enabled in production mode by default
  • Transport should be handled outside of the process via STDOUT and STDERR, not inside (this is the job of DevOps)
  • Configuration should also be handled outside of the code, not inside (also the job of DevOps)
  • Doesn't allow for fancy configurations that are easy to get wrong. Logging should be easy and simple.

Simple & Easy to Use 😃

  • Automatic Error serialization
  • Out-of-the-box Typescript support
  • Only 2 tiny dependencies, written in clean Typescript
  • Nice human readable output

Flexible & Powerful 💪

  • Easily set configuration using simple CLI overrides
  • Simple and well-defined enough to build custom tooling around, such as custom error handling and logging pipelines.

Installation

npm i jsout

Example Usage

import {logger} from 'jsout';

logger.info('test message');
logger.fatal('oops!', new Error(), {foo: 'bar'})
logger.error('', new Error('test')); //infers "test" as message

## Express.js HTTP Request Logger

See [jsout-express](https://github.com/mhweiner/jsout-express)

Configuration

Configuration is set through the CLI environment variables (aka process.env variables in node.js). For example, here is a recommended setup for local development:

LOG=debug LOG_FORMAT=human LOG_VERBOSITY=terse node /path/to/yourApp.js

process.env.LOG

Sets the log level. Any logs lower than this log level are ignored.

Possible values: "trace", "debug", "info", "warn", "error", "fatal"

Default: "info" (recommended for production)

process.env.LOG_FORMAT

Set the format for the output to either be human-readable (great for local development in the console), or JSON formatted (great for data aggregation on a server).

Possible values: "human", "json"

Default: "json" (recommended for production)

process.env.LOG_VERBOSITY

If verbose, extra metadata is appended to log.context. Example:

{
  "date": "2021-12-19T06:17:38.147Z",
  "pid": 71971,
  "ppid": 71970,
  "nodeVersion": "v16.13.0"
}

Possible values: "terse", "verbose"

Default: "verbose" (recommended for production)

API

For all of the following, please note:

  • error should be an actual Error object with stack traces. This is not enforced.
  • context should by any information not necessarily directly related to the error, ie. server request information, app component, configurations, etc. This is where the verbose metadata is appended (this will override anything in the context object).
  • data any object that might be useful to debug the error, or any pertinant information relating to the log message

logger.trace(message?: string, data?: any, context?: any)

Emits a log to stdout with a level of TRACE (10)

logger.debug(message?: string, data?: any, context?: any)

Emits a log to stdout with a level of DEBUG (20)

logger.info(message?: string, data?: any, context?: any)

Emits a log to stdout with a level of INFO (30)

logger.warn(message?: string, error?: any, data?: any, context?: any)

Emits a log to stderr with a level of WARN (40)

logger.error(message?: string, error?: any, data?: any, context?: any)

Emits a log to stderr with a level of ERROR (50)

logger.fatal(message?: string, error?: any, data?: any, context?: any)

Emits a log to stderr with a level of FATAL (60)

Contribution

Please contribute to this project! Issue a PR against master and request review.

  • Please test your work thoroughly.
  • Make sure all tests pass with appropriate coverage.

How to build locally

npm i

Running tests

npm test