# @dinuovos/node-logger

> A Logger extensions for node.js. Create to color console messages, and write them on specified file # Usage ```sh npm install @dinuovos/node-logger ``` ```js (async(){ var logger = require(@dinuovos/node-logger); var cons = await logger("test");

Latest version **1.0.1** (published 2019-03-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @dinuovos/node-logger
pnpm add @dinuovos/node-logger
yarn add @dinuovos/node-logger
bun add @dinuovos/node-logger
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-03-28 |
| First published | 2019-03-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.10.1 |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Simone Di Nuovo |
| Maintainers | dinuovos |

## Links

- npm: https://www.npmjs.com/package/@dinuovos/node-logger
- npm.io page: https://npm.io/package/@dinuovos/node-logger

## Recent versions

- 1.0.1 (latest) — 2019-03-28
- 1.0.0 — 2019-03-27

## README

# Logger
A Logger extensions for node.js.
Create to color console messages, and write them on specified file
# Usage
```sh
npm install @dinuovos/node-logger
```
```js
(async(){
var logger = require(@dinuovos/node-logger);
var cons = await logger("test");
console.log("this is a test");
console.log("FgGreen", "this is a test with color");
console.log("FgBlue", "this is a test with color", "with", "more", "commas.");
console.warn("This is a warn");
console.error("This is an error");
cons.destroy();
console.log("FgGreen", "I've called destroy, and now you see FgGreen at the start of this sentence");
cons = await logger("test", null, "./test-logger.log", 'w');
console.log("Now i'm writing on ./test-logger.log with mode 'write' ( no old logs )");
console.warn("This is a warn");
console.error("This is an error");
console.log("Check it on ./test-logger.log");
cons.destroy();
console.log("FgGreen", "Re-called destroy, no more logger console");
cons = await logger("test", true, "./test-logger.log");
console.log("Now i'm writing on ./test-logger.log with mode 'append', no log on CLI1!");
console.log("Now i'm writing on ./test-logger.log with mode 'append', no log on CLI2!");
console.log("Now i'm writing on ./test-logger.log with mode 'append', no log on CLI3!");
})();
```
# Error example:
```js
const logger = require(@dinuovos/node-logger);
logger("prova", null, "./test-logger2.log", 'w').then(()=>{
        throw new Error("throwing an error now. To test if test-logger2.log is written");
}).catch((err)=>{
        console.error(err.stack);
});
```
# Console colors
```json
module.exports = {
    Reset : "\x1b[0m",

    Bright : "\x1b[1m",
    Dim : "\x1b[2m",
    Underscore : "\x1b[4m",
    Blink : "\x1b[5m",
    Reverse : "\x1b[7m",
    Hidden : "\x1b[8m",

    FgBlack : "\x1b[30m",
    FgRed : "\x1b[31m",
    FgGreen : "\x1b[32m",
    FgYellow : "\x1b[33m",
    FgBlue : "\x1b[34m",
    FgMagenta : "\x1b[35m",
    FgCyan : "\x1b[36m",
    FgWhite : "\x1b[37m",

    BgBlack : "\x1b[40m",
    BgRed : "\x1b[41m",
    BgGreen : "\x1b[42m",
    BgYellow : "\x1b[43m",
    BgBlue : "\x1b[44m",
    BgMagenta : "\x1b[45m",
    BgCyan : "\x1b[46m",
    BgWhite : "\x1b[47m"
};
```

---
_Source: https://npm.io/package/@dinuovos/node-logger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
