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

leg

v1.1.0

Published

lig leg log

Downloads

10

Readme

leg

logs of json

Overview

leg! leg because lel! leg is a stupidly simple JSON-based logging thingy. It works the way I want it to, and you might also garner some utility from it. If not, that's fine.

Super Quickstart

var log = require("leg")();

log.info("something happened!", {some: "other", things: "here"});
["2013-05-13T04:11:00.664Z","INFO","something happened!",{"some":"other","things":"here"}]

Installation

Available via npm:

$ npm install leg

Or via git:

$ git clone git://github.com/deoxxa/leg.git node_modules/leg

API

leg

Creates a new logging function thing. Optionally takes a writable stream to output to as an argument. By default, will use process.stderr. The return value is a function that you can use to log things!

leg([stream], [options]);
// instantiate with default process.stderr output
var log = leg();

// instantiate with different output
var log = log(process.stdout);

// instantiate with options
var log = log(null, {object: true});

log

This is the return value of leg(). It takes three arguments, with the last one being optional. It also has a few convenience things tacked onto it, read on below for more info on them.

log(level, text, [info]);
// log without any context information
log("EMERGENCY", "there are very few donuts left");

// log with some useful context data
log("EMERGENCY", "there are very few donuts left", {donutCount: 3});
["2013-05-13T04:13:51.640Z","EMERGENCY","there are very few donuts left",null]
["2013-05-13T04:13:51.640Z","EMERGENCY","there are very few donuts left",{"donutCount":3}]

Arguments

  • level - the coarse level of the log message. e.g. "ERROR"
  • text - the main text body of the message. e.g. "received request"
  • info - any kind of JSON.stringify-able value (default null)

debug info warn error

These are all properties of the log function. They just provide a suggested set of log levels. You can even create your own!

log.debug(text, info)
log.info(text, info)
log.warn(text, info)
log.error(text, info)
log.debug("some debugging info", {someMetric: 12345});
["2013-05-13T04:20:50.477Z","DEBUG","some debugging info",{"someMetric":12345}]

Arguments

  • text - same as text in log
  • info - same as info in log

Creating your own

log.silly = log.bind(log, "SILLY");
log.silly("yippee", {woo: "hoo"});
["2013-05-13T04:22:36.299Z","SILLY","yippee",{"woo":"hoo"}]

License

3-clause BSD. A copy is included with the source.

Contact