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

bind-std-to-console

v1.1.0

Published

Run node with --inspect and see what is in your stdout and stderr. Simple like first import in your app boot.

Downloads

37

Readme

bind-std-to-console

Run node with --inspect and see what is in your stdout and stderr. Simple like first import in your app boot.

It should be used only in development mode. It will reduce your production server performance.

Motivation

I've been using Winston logger for a while now, and I usually have my Node inspector open in development. For the right reasons Winston console transport log directly to stdout and stderr instead of using the console.log and console.error from Node JS.

This small module will help you to see all of that messages in your inspector window. But again, don't use it for production!

The reason that Winston sends directly to stdout/stderr is that those streams are nonblocking implementations and it will have a small performance impact in your application. The Console API documentation have a friendly warning:

Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O for more information.

That's why you should never run this in production. It will only start automaticaly if it's in a development. Enjoy it :)

How to install

npm install bind-std-to-console --save-dev

Before to your app before other libs, as closes as to the first line, most probably you will capture all the stdout and stderror output.

require('bind-std-to-console');
// The logic from your server app

Custom bind

By default stdout will bind to console.log and stderr will bind to console.error, that is customizable to reduce the noise in the console.

Example to bind it to console.debug and console.warn:

const bstd = require('bind-std-to-console');
bstd.stdoutToConsole = console.debug;
bstd.stderrToConsole = console.warn;

Demo

Enabled: module enabled

Disabled: module disabled