5. Set Options

Set Options

In this example, print formatting is dempnstrated.

  • Suppress messages higher than level 2.
  • Change month format to "2-digit"
  • Print file names in blue.

File : setOptions.js

const net = require('net');
const debug = require('pretty-debug');

debug.setOptions({
	debugLevel: 2,
	funcName:{
		show: false
	},
	dateTime:{
		format: {
			month: "short"
		}
	},
	fileName:{
		color : debug.color.blue
	}
});

debug.info('Example : Set Options');

function test(){
	debug.log('The is level 1 : LOG');
	debug.info('The is level 2 : INFO');
	debug.alert('The is level 3 : ALERT');
	debug.warn('The is level 4 : WARN');
	debug.error('The is level 5 : ERROR');
	debug.critical('The is level 6 : CRITICAL');
}

test();

Run Example

To run the above example simply run the command below

$ node setOptions.js

Output

Output

-----------------------------------------------------