2.0.0 • Published 6 years ago

footstep v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

footstep

footstep is a simple robust logger for nodejs

Installation

$ npm install --save footstep  

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  
  
  
// verbose & debug will not execute if they  
// aren't enabled. You can enable/disable them  
// via the options or the following functions.  
logger.setVerbose(true);  
logger.setDebug(true);  

Options

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

variablesdefaulttype
streams.verboseprocess.stdoutStream
streams.infoprocess.stdoutStream
streams.errorprocess.stderrStream
streams.warningprocess.stdoutStream
streams.noticeprocess.stdoutStream
streams.debugprocess.stdoutStream
streams.logprocess.stdoutStream
format{{date}} {{type}}: {{message}}String
formats.dateFunction() {}Function
formats.messageFunction() {}Function
formats.prefixFunction() {}Function
formats.typeFunction() {}Function
prefixString
eolos.EOLString
debugfalseBoolean
verbosefalseBoolean

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'],
	      date  = new Date()
	    ;
        return days[date.getDay()];  
      }  
    }
  }
;

Output:
[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.

Colors

Footstep has built in support for colors and styles with help & similar syntax to colors.js.

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
  • .blue
  • .cyan
  • .gray
  • .green
  • .grey
  • .magenta
  • .red
  • .white
  • .yellow
  • .bg_black
  • .bg_blue
  • .bg_cyan
  • .bg_gray
  • .bg_green
  • .bg_grey
  • .bg_magenta
  • .bg_red
  • .bg_white
  • .bg_yellow
  • .bold
  • .dim
  • .hidden
  • .inverse
  • .italic
  • .strikethrough
  • .underline
2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago