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

@hamistudios/footstep

v2.3.3

Published

a simple robust nodejs logger

Downloads

2

Readme

footstep logo

footstep

footstep is a simple robust logger for nodejs

Build Status Coverage Status npm version license

Installation

$ npm install --save @hamistudios/footstep  

Documentation

Logger

Setup

const { Logger } = require("footstep");  
  
let logger = new Logger(options);  

Usage

logger.verbose("Hello World");  // => [10:34:35] verbose: Hello World
logger.info("Hello World");     // => [10:34:35] info: Hello World
logger.error("Hello World");    // => [10:34:35] error: Hello World
logger.warning("Hello World");  // => [10:34:35] warning: Hello World
logger.notice("Hello World");   // => [10:34:35] notice: Hello World
logger.debug("Hello World");    // => [10:34:35] debug: Hello World
logger.log("Hello World");      // => [10:34:35] log: Hello World

Options

Footstep comes with a lot of useful options to help customize your log messages including, custom streams, prefixes and functional expansions.

| variables | default | type | |----------------- |----------------------------------------------------|----------------------| | streams.verbose | process.stdout | Stream|Function | | streams.info | process.stdout | Stream|Function | | streams.error | process.stderr | Stream|Function | | streams.warning | process.stdout | Stream|Function | | streams.notice | process.stdout | Stream|Function | | streams.debug | process.stdout | Stream|Function | | streams.log | process.stdout | Stream|Function | | streams.clear | process.stdout | Stream|Function | | format | [{{date}}] {{type}}: {{message}} | String | | formats.date | Function() {} | Function | | formats.message | Function() {} | Function | | formats.type | Function() {} | Function | | prefix | | String | | eol | os.EOL | String | | debug | false | Boolean | | verbose | false | Boolean | | maxLogHistory | 50 | Integer | | clearCodes.full | \x1b[2J | String | | clearCodes.standard | \x1b[0f | String |

Custom expansions

You can create custom function expansions by adding a new function to formats

const options = {
  format  : '[{{dow}}] {{message}}',
  formats : {
    dow     : function() {
      let days  = [ 'Sunday','Monday','Tuesday',
        'Wednesday','Thursday','Friday', 'Saturday' ],
      let date  = new Date();
      
      return days[date.getDay()];  
    }  
  }
};

let logger = new Logger(options);

logger.log('Hello World'); // => [Thursday] Hello World 

Streams

You can set the stream to anything with the instance of Stream including process.stdout, process.stderr, fs streams, HTTP streams etc.

Methods

.setVerbose

Set whether verbose logs should be sent to the stream.

Syntax
logger.setVerbose(boolean: value)

.setDebug

Set whether debug logs should be sent to the stream.

Syntax
logger.setDebug(boolean: value)

.clear

Clear the log output

Syntax
logger.clear(full: boolean)

.blank

Print a blank line to the specified stream

Syntax

logger.blank([StreamName: stream])

Example

logger.blank(StreamName.ERROR); // print a blank line to the error stream

.getPastLogs

Get an array of past logs (max log history specified via options.maxLogHistory)

Syntax

logger.getPastLogs()

.pad

Add padding to an array of strings to make them all the same length

Syntax

logger.pad(string[]: strings, [boolean: start=true])

Example

logger.pad(['test', 'testing']); // => ['   test', 'testing']
logger.pad(['test', 'testing'], false); // => ['test   ', 'testing']

.verbose

Print to the verbose stream

Syntax

logger.verbose(any[]: args)

Example

logger.verbose('Sum (5+5)', 10);

.info

Print to the info stream

Syntax

logger.info(any[]: args)

Example

logger.info('Sum (5+5)', 10);

.error

Print to the error stream

Syntax

logger.error(any[]: args)

Example

logger.error('Sum (5+5)', 10);

.warning

Print to the warning stream

Syntax

logger.warning(any[]: args)

Example

logger.warning('Sum (5+5)', 10);

.notice

Print to the notice stream

Syntax

logger.notice(any[]: args)

Example

logger.notice('Sum (5+5)', 10);

.debug

Print to the debug stream

Syntax

logger.debug(any[]: args)

Example

logger.debug('Sum (5+5)', 10);

.log

Print to the log stream

Syntax

logger.log(any[]: args)

Example

logger.log('Sum (5+5)', 10);

Colors

Footstep has built in support for colors and styles, you can use these to bring your logs to life.

Usage

const { Colors } = require("footstep");

console.log('I am red and underlined'.red.underline);  
console.log('I am blue and bold'.blue.bold);  
console.log('I am black with a white background'.black.bg_white);  
console.log('I am black with a red background'.red.inverse);
console.log(color.strip('I am no color'.yellow));

List of colors & styles

  • .reset
  • .black
  • .red
  • .green
  • .yellow
  • .blue
  • .magenta
  • .cyan
  • .white
  • .gray
  • .gray
  • .bright_black
  • .bright_red
  • .bright_green
  • .bright_yellow
  • .bright_blue
  • .bright_magenta
  • .bright_cyan
  • .bright_white
  • .bg_black
  • .bg_red
  • .bg_green
  • .bg_yellow
  • .bg_blue
  • .bg_magenta
  • .bg_cyan
  • .bg_white
  • .bright_bg_black
  • .bright_bg_red
  • .bright_bg_green
  • .bright_bg_yellow
  • .bright_bg_blue
  • .bright_bg_magenta
  • .bright_bg_cyan
  • .bright_bg_white
  • .bold
  • .faint
  • .italic
  • .underline
  • .slow_blink
  • .rapid_blink
  • .inverse
  • .hidden
  • .strikethrough
  • .framed
  • .encircled
  • .overlined