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 🙏

© 2026 – Pkg Stats / Ryan Hefner

logsaw

v0.1.0

Published

A simple JSON file-based logger for node

Readme

logsaw

logsaw is a simple JSON file-based logger for node.

Installation

npm

npm install logsaw

GitHub

npm install https://github.com/martinrue/logsaw/tarball/master

Configuration

To change the default config, call configure:

var logger = require('logsaw');

logger.configure({
  console: true,
  verbose: true,
  directory: __dirname + '/logs'
});

Options

| Key | Default Value | Description | |-------------|--------------------------|------------------------------------------------------| | console | true if not production | display logs on console | | verbose | false | display complete log object on console | | debug | false | save debug logs to log file | | generators | false | allow log functions to be yielded from ES6 generator | | directory | process.cwd() + 'logs' | the directory to write log files to (created if new) |

API

logsaw exposes 4 functions: debug(), info(), warn() and error(). All functions take a single object argument which may contain message, context and data fields. You may specify a type field in calls to info() to create custom log types. Calls to debug() are saved to the log file only if { debug: true } is set in config.

Example

var logger = require('logsaw');

// creates a debug log (saved to the log file if debug is set to true in config)
logger.debug({ message: 'some debug message', data: { /*...*/ } });

// creates an info log
logger.info({ message: 'user signed up' });

// creates a custom user-signup log
logger.info({ type: 'user-signup', message: 'user signed up' });

// creates a warning log with a context
logger.warn({ message: 'account locked', context: '[email protected]' });

// creates an error log with associated err data
logger.error({ message: 'something went wrong', data: err });

Callback

If { generators: false } is set (default), an optional callback can be supplied as the last argument to the 4 logging functions to be notified once the underlying write operation completes.

Generators

If { generators: true } is set, you can optionally yield any of the 4 log functions from within Co, or similar.

Logs

Filename

Log files are created based on the current date (e.g. 2014-07-22.log) and written to the config directory.

Format

Each log file consists of a line-delimited JSON entry of the form:

{
  "type":"error",
  "message":"something went wrong",
  "time":"2014-07-22T19:30:00.630Z",
  "data":"{ err: 'error info' }",
  "context":"[email protected]"
}

Context

The context field of a log entry is intended to hold a scalar value that can be used to group sets of logs together.

You could set it to a user's email address to associate a series of logs with a user, you could set it to a request ID to associate a series of logs with an HTTP request, or you could set it to some other meaningful value.

License

MIT