1.1.4 • Published 7 years ago

debugmessage v1.1.4

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

Description

debugmessage is a simple module for node.js that provides utility to write colored command line in debug nodejs script

Requirements

Install

npm install debugmessage

Examples

  • simple base method to write cmd message colored (es6)
import {DebugMessage} from "debugmessage";
let log=new DebugMessage();
log.debug("this is only a debug");
log.command("this is only a command");
log.error("this is a error");

write on console

[DEBUG] this is only a debug
[COMMAND] this is only a command
[ERROR] this is only a error

DEBUG is a cyan foreground color COMMAND is a yellow foreground color ERROR is a red foreground color

description

module debugmessage use ansi colors to colorize the console log label on squares. Each color is a single method write it in lowercase

Foreground colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Background colors

  • bgblack
  • bgred
  • bggreen
  • bgyellow
  • bgblue
  • bgmagenta
  • bgcyan
  • bgwhite 
import {DebugMessage} from "debugmessage";
let log=new Message();
let green=log.green("message green");
console.log(green);//normal console but colored
//or you can print with module
log.printMessage("message","green");
//use background color green
log.printMessage("message","bggreen");
//-------------------------
// simple test
log.test();

npm run test (grunt run:test)

Alt text

API

Events

Property

  • print< boolean >: show/hide message in commandline

Methods

  • (constructor)() - Creates the dynamic sequences colors method.
  • addLabel(labelstring:string,color:string):string
    • DESCRIPTION: create new method lowercase to write message with LABEL. the name of method is the LABEL in lowercase.(see example)
      • labelstring - new label
      • color - one of foreground or background. Default: cyan
  • message(message:string,color:string):string
    • DESCRIPTION: return colored string
      • message - message to message to color. Default: null
      • color - one of foreground or background. Default: cyan
  • info(message:string,stack...): void
    • DESCRIPTION: write in cmd a colored message with prefix label "INFO" blue
      • message - message to message to color. Default: null
      • stack - message to append with label INFO STACK ...
  • event(message:string,stack...): void
    • DESCRIPTION: write in cmd a colored message with prefix label "EVENT" blue
      • message - message to message to color. Default: null
      • stack - message to append with label EVENT STACK ...
  • debug(message:string,stack...): void
    • DESCRIPTION: write in cmd a colored message with prefix label "DEBUG" cyan
      • message - message to message to color. Default: null
      • stack - message to append with label DEBUG STACK ...
  • command(message:string): void

    • DESCRIPTION: write in cmd a colored message with prefix label "COMMAND" yellow
      • message - message to message to color. Default: null
      • stack - message to append with label COMMAND STACK ...
  • error(message:string): void

    • DESCRIPTION: write in cmd a colored message with prefix label "ERROR" red. Error message have line before and after the message.
      • message - message to message to color. Default: null
      • stack - message to append with label ERROR STACK ...
  • printMessage(message:string,color:string):void

    • DESCRIPTION: print in cmd the colored message
      • message - message to message to color. Default: null
      • color - one of foreground or background. Default: cyan

Extend before 1.1.4

class Message extends DebugMessage{
	constructor(){super();}
	error(m,...p){
		super.error(m,...p);
		process.exit();//this lock node process
	}
	warning(message){
		this.printMessage(message,"bgyellow");
	}
	event(message){
		let label = this._msglabel_("EVENT", "magenta");
		this.printMessage(`${label} ${message}`);
	}
}

Extend after >=1.1.4

mymessage= new DebugMessage();
mymessage.addLabel("labelCustom","bgyellow");
mymessage.labelcustom("a new custom label");

CHANGE LOG

  • 1.1.4 added the dynamic addition to create label
    • new label message "info" e "event"
  • 1.1.3 fix on documentation
1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago