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

fm-log

v4.4.3

Published

Console logging facility for Node

Downloads

16

Readme

fm-log

npm Package Coverage Status Code Climate GitHub license

What?

Straight-forward logging module.

  • lines up everything in nice columns
  • uses colors
  • sends everything straight to process.stderr (no events, no nextTick()) if desired
  • condenses repeated messages
  • displays stack traces for logged Error instances and other multi-line content nicely
  • optionally displays the source of the logging call
  • supports wrapping of morgan in your express app
  • can replace the debug module, using hartwig-at/debug

Example

var log = require( "fm-log" ).module( "demo" );

log.info( "Logging without source tracing" );
log.notice( "Initializing application...\nwow\nsuch application" );
log.critical( new Error( "Logging an Error instance." ) );

log.withSource();
log.info( "Logging WITH source tracing" );
log.notice( "You'll never know where this was logged from!" );

log = require( "fm-log" );
log.warn( "We don't need no prefix!" );

log = require( "fm-log" ).module( "something weird" );
log.warn( "...or do we?" );

log = require( "fm-log" );
log.notice( "You're using a longer prefix? I'll adjust." );

log = require( "fm-log" ).module();
log.error( "ouch" );

// Wrap morgan
app.use( require( "fm-log" ).module( "HTTP" ).morgan( {format : "dev"} ) );

How?

Install

npm install fm-log

Put this in every file where you want to log:

var log = require( "fm-log" ).module();

Then just use log.info or one of the other logging levels shown above.

For loggers without a specific prefix, just require() the module and use it directly:

var generic = require( "fm-log" );
generic.notice( "We don't need no prefix" );

To log to a different stream (process.stdout is the default), use .to():

var logger = require( "fm-log" ).to( process.stderr );

To send data straight to the output stream (without nextTick()), use .sync():

var logger = require( "fm-log" ).sync();