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

fun-bunyan

v1.1.0

Published

A noise-free Bunyan logger that writes to the console. It makes using Bunyan in development **fun**.

Downloads

6

Readme

fun-bunyan

Easy console logging for Node apps. Use the fun-bunyan console stream for projects that are already using Bunyan, or create a new Bunyan instance for development with one line of code.

Powered by bunyan.

Build Status Coverage Status

Installation

npm install fun-bunyan

Usage

To use the logger:

const { FunBunyan } = require('fun-bunyan');
const logger = new FunBunyan();

logger.info('Yay, so easy!');
logger.info(`Yay, it\s Bunyan, so I won't have to edit all my logging code
                in three months when I stream logs to XYZ service!`);
logger.info({
    feels: 'liberating'
}, "Like a weight removed from my shoulders.");

Add random streams to a new FunBunyan instance. Here we can see the raw JSON from Bunyan interlaced with the cleaned-up output from fun-bunyan.

const { FunBunyan } = require('fun-bunyan');
const funBunyan = new FunBunyan({
    streams: [
        {
            level: 'info',
            stream: process.stdout
        }        
    ]
});
funBunyan.info(`Yay, I'm seeing double!`);

Configure the output with a few simple options:

const { FunBunyan } = require('fun-bunyan');
const funBunyan = new FunBunyan({
    streams: [
        {
            level: 'info',
            stream: process.stdout
        }        
    ],
    level: 'trace',
    console: {
        logTemplate: '{%s}*(%s)*%s',
        errorTemplate: '{%s}#(%s)#%s\n%s',
        stdout: console.log,
        stddir: console.dir,
        stderr: console.error,
        stringify: 'simple',
        colors: false
    }
});
funBunyan.trace(`Yay, We're tracing.`);
funBunyan.trace(`Yay, You can see everything twice.`);

const hello = {
    foo: 'bar',
    bar: true,
    baz: 123.45
};
hello.barf = hello; // Include a circular reference!

funBunyan.trace({ hello }, `Yay, Objects passed to log methods are safely stringified. 
                                Even ones with circular references!`);

By default, the output is colorized, but you could turn colors off by passing false, or provide (some or all of) your own color map.

const { FunBunyan } = require('fun-bunyan');
const funBunyan = new FunBunyan({
    console: {
        colors: {
            "bold": "\x1b[1m",
            "reset": "\x1b[0m",
            "time": "\x1b[34m",
            "fatal": "\x1b[35m",
            "error": "\x1b[31m",
            "warn": "\x1b[33m",
            "info": "\x1b[36m",
            "debug": "\x1b[37m",
            "trace": "\x1b[90m"
        }
    }
});
funBunyan.trace(`Yay, We're using a custom color map!`);

If you're already using Bunyan for your logging, you can simply add the fun-bunyan console stream to your existing streams array when running in development.

const bunyan = require('bunyan');
const funBunyan = require('fun-bunyan');

const streams = [
    // Log to Stackdriver or other...
    // stackdriver.stream(options.level || 'info');
];

if (process.env.NODE_ENV === 'development') {
    streams.push({
        stream: funBunyan.stream(),
        type: "raw",
        level: "info",
    });
}

const logger = bunyan.createLogger({
    name: 'example',
    streams
});

logger.info(`Look Ma, I'm logging to the console!`);