console-x
v2.0.2
Published
Enhanced JavaScript console logger
Downloads
6
Maintainers
Readme
consoleX.js
Enhanced console logging functionality
Features
- Different colors for message levels: log, notify, warn, err. These colors can be customized.
- Messages specified in the form of a summary (which is colored) and content (which retains default color), so that color is used judiciously, making messages clearer
- Option to add a semicolon after message summary
- Option to specify a prefix function that generates a consistent prefix (displayed in gray) for messages
API
consoleX(options).configure(options)
consoleX(options).log(summary,description)
consoleX(options).notify(summary,description)
consoleX(options).warn(summary,description)
consoleX(options).err(summary,description)
Example
const consoleX = require('console-x').configure({
separator: "\n", // appended after each individual log to screen; default is newline
summaryColon: true, // whether to append colon after summary; default is true
getPrefix: function() { return "Test Message>>" }, // prefix function; default is timestamp; pass null to disable
colors: {
log: "white", // default
notify: "green", //default
warn: "yellow", //default
err: "red" //default
}
});
consoleX.log ("Eureka", "I have found it")
consoleX.notify ("Eureka", "I have found it")
consoleX.warn ("Eureka", "I have found it")
consoleX.err ("Eureka", "I have found it")
Install
npm install console-x --save