my-console
v1.6.0
Published
Use console with timestamp and controll it in production version.
Downloads
16
Maintainers
Readme
my-console
Drop-in replacement for console
- a cross-environment fix for missing methods.
Installation
Just include the script. The host my-console
object is automatically updated in your environment. No need for new
or any other sort of initialization.
Node.js
$ npm [-g] install my-console
Then require the "my-console" module:
var console = new (require("my-console")).Console();
Reset the Log level
* console.level = console.LEVELS.DEVELOPMENT; // default
* console.level = console.LEVELS.INFO;
* console.level = console.LEVELS.WARN;
* console.level = console.LEVELS.ERROR;
* console.level = console.LEVELS.LOG;
* console.level = console.LEVELS.SUCCESS;
* console.level = console.LEVELS.PRODUCTION;
* console.level = [console.LEVELS.LOG,console.LEVELS.INFO];
* console.level = []; //stop all logs
#Examples
/**
* Created by pawanpawar on 3/6/17.
*/
var console = new (require("./console")).Console();
console.datetime = true;
console.fileName = true;
console.lineNumber = true;
console._repeater = true;
console.repeater("=", 100);
console.info("Default console level (DEVELOPMENT)");
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("#", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.info("Setting console level to INFO");
console.level = console.LEVELS.INFO;
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("@", 100)
console.level = console.LEVELS.DEVELOPMENT;
console.info("Setting console level to WARN");
console.level = console.LEVELS.WARN;
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("$", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.info("Setting console level to LOG");
console.level = console.LEVELS.LOG;
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("%", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.info("Setting console level to ERROR");
console.level = console.LEVELS.ERROR;
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("^", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.info("Setting console level to PRODUCTION");
console.level = console.LEVELS.PRODUCTION;
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("&", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.info("Setting console level to WARN and LOG");
console.level = [console.LEVELS.WARN, console.LEVELS.LOG];
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("*", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.info("Setting console level to INFO and ERROR");
console.level = [console.LEVELS.INFO, console.LEVELS.ERROR];
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("~", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.info("Stop all console msgs.");
console.level = console.LEVELS.STOP;
console.log("I am `console.log` example");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.repeater("+", 100);
console.level = console.LEVELS.DEVELOPMENT;
console.repeater("/", 100);
console.info("Setting console level to INFO and LOG");
console.level = [console.LEVELS.INFO, console.LEVELS.LOG];
console.log("I am `console.log` example");
console.assert(false, "I am `console.assert` example and condition is false");
console.assert(true, "I am `console.assert` example and condition is true");
console.info("I am `console.info` example");
console.error("I am `console.error` example");
console.warn("I am `console.warn` example");
console.success("I am `console.success` example");
console.repeater("-", 100);
console.info('Also add new functions');
console.info('console.profile(reportName)');
console.info('console.profileEnd()');
console.info('console.select(element)');
console.info('console.table(tabularData)');
console.info('console.time(label)');
console.info('console.timeEnd(label)');
console.info('console.timeStamp(label)');
console.info('console.timeline(label)');
console.info('console.timelineEnd(label)');
#The above example will output: