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

yalog

v0.0.5

Published

Logging module that allows for custom levels and custom output support

Downloads

12

Readme

yalog... Yet Another Logger

yalog is a Node.js logging library that can

  • print log messages according to your own functions
  • be customized per module and per logging level
  • have any amount of logging levels
  • print statements in full color (background too!!!)
  • print statements with console qualities such as "italics" or "bold"
  • print messages with module name and current line number so you know from where it was called
  • be configured from file or by a module

Install

npm install yalog

Usage

Add to your code:

var log = require('yalog').with(module);

module is object defined automatically by Node.js. This allows you to copy and paste the line into each file and leverage your filename. The file name matching is done with module.id or the filename with the working directory and trailing '.js' removed. If you don't want automatic module names, replace it with your desired string name.

var log = require('yalog').with("myCustomName");

Arguments are not inspected unless the log level allows for printing of the statement. This avoids unnecessary object serialization calls before submitting your log statements.

log.info(arg1, arg2, arg3);

Simple Example

var log = require('yalog').with(module);
log.test( "Test"  , 0);
log.trace("Trace" , 1);
log.debug("Debug" , 2);
log.info( "Info"  , 3);
log.warn( "Warn"  , 4);
log.error("Error" , 5);
log.info('Array =', [1, 2, 3, 4], '; Object = ', {one: 1, two: 2});

// 2012-02-16T03:32:29.083Z TRACE main:23 - Trace 1
// 2012-02-16T03:32:29.085Z DEBUG main:24 - Debug 2
// 2012-02-16T03:32:29.085Z INFO  main:25 - Info 3
// 2012-02-16T03:32:29.085Z WARN  main:26 - Warn 4
// 2012-02-16T03:32:29.086Z ERROR main:27 - Error 5
// 2012-02-16T03:32:29.086Z INFO  main:28 - Array = [ 1, 2, 3, 4 ] ; Object =  { one: 1, two: 2 }

Advanced Example

Take a look at the examples directory for different examples.

// Load yalog configuration from another location to keep configurations in one spot.
var maxHelper = require('./examples/max_utilization_helper')
var log = maxHelper.with(module);

var answerObj = {is: 42};
answerObj.and = answerObj;

var ctxObj = {email: "[email protected]", circularObj: answerObj, other: "contextInfo", fn: function(){return true;}};
maxHelper.add_context_flag(ctxObj);

log.info( ctxObj, "The answer to life the universe and everything: '", answerObj, "'")
log.info( ctxObj, "Info counter should be at 2. Counter value:")
log.debug(ctxObj, "Debug counter should be at 1. Counter value:")
log.trace(ctxObj, "this should not execute. Level is not included (too low in stack)")
log.info( ctxObj, "Current 'ctxObj' obj: ", ctxObj)

// 2012-02-16T03:29:12.141Z; [email protected]; INFO ; main:12; -; The answer to life the universe and everything: ' | { is: 42, and: [Circular] } | '; 1
// 2012-02-16T03:29:12.145Z; [email protected]; INFO ; main:13; -; Info counter should be at 2. Counter value:; 2
// 2012-02-16T03:29:12.145Z; [email protected]; DEBUG; main:14; -; Debug counter should be at 1. Counter value:; 1
// 2012-02-16T03:29:12.145Z; [email protected]; INFO ; main:16; -; Current 'ctxObj' obj:  | { email: '[email protected]', circularObj: { is: 42, and: [Circular] }, other: 'contextInfo', fn: [Function], _myContextFlag: true }; 3

Changes

Dev Development

make compile  # compile files
make watch    # constantly watch files

License

Released under MIT License. Enjoy and Fork!