node-log-js
Tiny logging module. Inspired by npm/debug.
Contents
Installing
Using npm
:
$ npm install @architelos/node-log-js
Usage
- Import
node-log-js
:
import Logger from "@architelos/node-log-js";
// or
const Logger = require("@architelos/node-log-js");
- Create a new
Logger
instance:
let logger = new Logger();
- Create a new logger:
let logger = logger.Logger("worker", "37", "error");
Available parameters:
Name | Type | Description | Default |
---|---|---|---|
loggerName |
string |
Name of the logger | "logger" |
loggerColor |
string |
ANSI color code of the log message |
"37" |
loggerLevel |
string |
Name of the console function. For example, log , error , warn
|
"log" |
- Use the logger:
logger("Hello! I am some text!");
LOGGER_ALLOW
can be set to a regex (or multiple regexes seperated by a ,
) to allow/disallow loggers from logging.
Additionally, the environment variable On Windows (cmd):
$ set LOGGER_ALLOW=""
On Windows (powershell):
$ $env:LOGGER_ALLOW=""
On Linux (bash):
export LOGGER_ALLOW=""
Contributing
Open a pull request, or submit a new issue.
License
See license
.