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

@brd.com/log

v0.1.0

Published

A simple, modern logging framework

Downloads

6

Readme

BRD-log

Another logging framework? Srsly? Yep. Other log frameworks are great, got no problem they exist, but they're usually not particularly transparent to use. brd-log is designed to seamlessly integrate into webpack-based systems (any modern loader/roller will probably work), start out impossibly lightweight, and grow with the needs of your application. The goal is basically to make logging painless and easy to use for you, and also make your code more portable, because every console. function does exactly what you would expect, and oh so much more.

Installing

npm i --save brd-log

To configure your webpack instance, add this rule:

{
  test: /(\.js)$/,
  exclude: /node_modules/,
  loader: 'brd-log/loader',
}

If you're a fan of vue single-file components, get your vue-loader rule to look a bit like this:

{
  loader: 'vue-loader',
  options: {
    loaders: {
      js: [
        /* default JS items, probably babel-loader... */,
        { loader: 'brd-log/loader', except: /node_modules/ }
      ]
    }
  }
}

Take a look at how the loader works, and if you want to automatically configure objects in your own way.

Once you've done that, you'll want to, at the very least, set up the "passthrough" middleware:

var Core =  require("brd-log/core");
Core.middleware.push(require("brd-log/middleware/passthrough"));

This makes it so that everything that gets logged actually prints to the console. By default it silently eats errors because that is the most simple setup imaginable, and by forcing you to set up at least one middleware rule to start, you can more easily build whatever functionality you desire.

Middleware

brd-log leverages a middleware pattern similar to express or redux. You can add layers of middleware to change the behavior and make brd-log suit your specific needs. Examples of middleware can be found in the middleware directory, but each middleware function takes the following arguments:

function noop(next,options,...args) {
  next(options,...args);
}

For example, you might want to prefix something useful to the front, in this case the file & log level:

Core.middleware.push(function(next,options,message,...args) {
  next(options,`[${option.level} in ${options.file}] ${message}`,...args);
})