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

lamlog

v2.0.1

Published

Simple and bereft logging solution for Nodejs AWS Lambda, focused on a tiny code footprint.

Downloads

1,172

Readme

lamlog

Simple logging solution for Node.js AWS Lambda projects. Focus on brevity, ie a tiny code footprint.

Usage

Child

Gets a child logger that will contain the parent history for each logging statement of that child. This allows you to track the specific path of execution that resulted in the logging statement.

Timer

To measure the amount of time elapsed between to points, first call const myTimer = logger.timer('nameOfTimer) then when you are ready to print out the time to console simply pass the timer as an argument to any of the logging methods such as debug logger.debug('My Timer',myTimer).

Levels

This has a progressive level of logging that allows you to change the verbosity of your application depending on the current runtime needs. For exmaple, you set your logging level to 'error' nothing below that point will be reported to the console.

Each logging statement matches console.log, in that you can pass in a message and an object. In fact, under the covers, it is only using console.log or console.error, just with a bit of formatting help and stops to help with verbosity.

  1. trace() - Intimate application behavior for a specific module.
  2. debug() - Detailed 'general' application behavior.
  3. info() - Configuration information.
  4. log() - Synonym for info, to be consistent with console.
  5. warn() - Problematic behavior that isn't application fatal.
  6. error() - Broken or failed behavior.
const Logger = require('lamlog');
const logger = new Logger({name:'Parent',level:'trace'});

/*
 * Changes the logging level.
 */
logger.setLevel('warn');

logger.trace(`My message ${variable} value.`);
logger.trace('My message',variable);

logger.debug(`My message ${variable} value.`);
logger.debug('My message',variable);

logger.info(`My message ${variable} value.`);
logger.info('My message',variable);

logger.log(`My message ${variable} value.`);
logger.log('My message',variable);

logger.warn(`My message ${variable} value.`);
logger.warn('My message',variable);

logger.error(`My message ${variable} value.`);
logger.error('My message',variable);

Timer

Allows for easy reporting on the duration of execution of code. Each timing is a point in time, so it can be safely passed into paralelle or promise chains to be referenced at multiple points in time.

const Logger = require('lamlog');
const logger = new Logger({name:'Parent',level:'trace'});

function SuperSpecial(_logger) {
  /*
   * Will take on the logging level of its parent logger, and each logging
   *  statement will reflect the object chain.
   */
  const logger = _logger.child({name:'SuperSpecial'});
  
  /*
   * Records the current time, so it can be reported in a logging statement later.
   */
  const timing = logger.timer('NameOfTimer');
  
  /*
   * A timer can be reported directly in a logging statment and 
   *  reported appropriately.
   */
  logger.info(timing);
  //2017-03-18T07:47:03.512Z [info]	Parent.SuperSpecial	NameOfTimer took 0.195009ms
}
import * as Config from 'lamcfg';
const logger = new Logger({name:'Parent',level:'trace'});

class SuperSpecial {

  constructor(_logger){
    this.logger = _logger.child("SuperSpecial");
  }

  superSpecial():void {
      
    /*
    * Records the current time, so it can be reported in a logging statement later.
    */
    const timing = logger.timer('NameOfTimer');
    
    /*
    * A timer can be reported directly in a logging statment and 
    *  reported appropriately.
    */
    logger.info(timing);
    //2017-03-18T07:47:03.512Z [info]	Parent.SuperSpecial	NameOfTimer took 0.195009ms
  }
}