Simple logging library for node.js.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mort 14f0179860 updated package.json version преди 10 години
.gitignore initial commit преди 10 години
README.md fixed README преди 10 години
index.js added log.error преди 10 години
package.json updated package.json version преди 10 години

README.md

mLogger

mLogger is a very simple logging library for node.js.

Installation

Install like any other NPM library:

npm install --save mlogger

Usage

var log = require("mlogger");

Logger has 4 methods for logging:

log.info("foo");   // yyyy/mm/dd HH:MM:SS INFO: foo
log.notice("foo"); // yyyy/mm/dd HH:MM:SS NOTICE: foo
log.warn("foo");   // yyyy/mm/dd HH:MM:SS WARNING: foo
log.error("foo");  // yyyy/mm/dd HH:MM:SS ERROR: foo
log.die("foo");    // yyyy/mm/dd HH:MM:SS ERROR: foo

After log.die, the process will immediately exit.

If an error object is passed instead of a string, a stack trace will be printed, like this:

log.notice(new Error("foo"));

// yyyy/mm/dd HH:MM:SS NOTICE: foo - stack trace:
// Trace: [Error: foo]
//     <stack trace>

To set a different color theme, use setTheme:

log.setTheme({
	timestamp: "green"
})

The available properties for setTheme is:

  • timestamp: timestamp, default: “blue”
  • level_0: logger.info, default: “grey”
  • level_1: logger.notice, default: “yellow”
  • level_2: logger.warn, default: “red”
  • level_3: logger.die/logger.error, default: [“bold”, “red”]

The available values for themes are listed here: https://npmjs.com/package/colors