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

bobble

v0.1.1

Published

Yet another node.js logger

Downloads

4

Readme

bobble

Yet another node.js logger

Build Status Dependencies by David Built with Grunt

Module Overview

bobble is a simple to use logging module. It can log to console, or a file and can also have custom log levels added that can be configured to log to different files.

Usage

In its simplest form, create an instance of bobble and call the log function to write to the console. Each logged line will be preceded with a timestamp, which is in UK format (DD-MM-YYYY HH:mm:ss.SSS) by default.

var bobble = require('bobble');
var logger = new bobble();

logger.log("Log this to console");

To change bobble's default behavior, pass in a configuration object when creating the new instance. For example, in order to change the timestamp date format, pass a 'dateFormat' parameter specifying the date format to use. bobble uses Moment.js to format its timestamps, so any format that is supported by Moment.js is also supported by bobble.

var bobble = require('bobble');
var logger = new bobble(
{
  'dateFormat' : 'MM-DD-YYYY HH:mm:ss.SSS'
});

logger.log("Log this to console");

In order to write output to a file instead of the console, pass a 'fileName' configuration parameter specifying the file to log to.

var bobble = require('bobble');
var logger = new bobble(
{
  'fileName' : 'mylog.log'
});

logger.log("Log this to mylog.log");

Custom Log Levels

To add custom logging levels to bobble, pass in an object with the log levels as the keys, followed by an object containing an optional file name to log to. The new log levels are added to bobble as functions and can be called instead of the log() method.

var bobble = require('bobble');
var logger = new bobble(
{
  'fileName' : 'default.log',
  'logLevels' :
  {
  	'warn' : { 'fileName' : 'warnings.log' },
	'error' : { 'fileName' : 'errors.log' },
	'info' : {}
  }
});

logger.warn("This is a warning logged to my warnings.log file");
logger.error("This is an error logged to my errors.log file");
logger.log("This will continue to be logged to default.log");
logger.info("This will also be logged to default.log");

Logging Object Properties

Custom log levels can also be used to output the properties of a passed object in a custom format. Pass the objectMapping parameter during the setup of a log level, then pass the object to log when calling the log level function:

var http = require('http');
var bobble = require('bobble');
var logger = new bobble(
{
  'fileName' : 'default.log',
  'logLevels' :
  {
  	'warn' : { 'fileName' : 'warnings.log' },
	'web' : { 
	  'fileName' : 'web.log', 
	  'objectMapping' : ['method', 'url'] 
	},
	'info' : {}
  }
});

var server = http.createServer(function(req, res){ 
	logger.log('Log req details to the web log.');
	logger.web(req);
}.listen(3000);