# forbidden-node-logger

> Logger package built for NodeJS

Latest version **1.4.2** (published 2020-10-30) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install forbidden-node-logger
pnpm add forbidden-node-logger
yarn add forbidden-node-logger
bun add forbidden-node-logger
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.4.2 |
| Published | 2020-10-30 |
| First published | 2020-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 44.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Duck#9999 |
| Maintainers | forbidden_duck |
| Keywords | console, console.log, logger, log, logs, node, nodejs, js, javascript, ts, typescript, file, support, colour, color, colours, colors, coloured, colored, info, debug, warn, error, json, simple, easy, powerful, efficient |

## Links

- npm: https://www.npmjs.com/package/forbidden-node-logger
- Repository: https://github.com/Forbidden-Duck/forbidden-node-logger
- Issues: https://github.com/Forbidden-Duck/forbidden-node-logger/issues
- npm.io page: https://npm.io/package/forbidden-node-logger

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.4.2 (latest) — 2020-10-30
- 1.4.1 — 2020-10-28
- 1.4.0 — 2020-10-25
- 1.3.4 — 2020-10-24
- 1.3.3 — 2020-10-24
- 1.3.2 — 2020-10-23
- 1.3.1 — 2020-10-06
- 1.3.0 — 2020-10-06
- 1.2.0 — 2020-10-05
- 1.1.2 — 2020-10-04
- 1.1.1 — 2020-10-04
- 1.1.0 — 2020-10-02
- 1.0.1 — 2020-10-02
- 1.0.0 — 2020-10-02

## README

Read [Github](https://github.com/Forbidden-Duck/forbidden-node-logger) README, in case of unpublished changes
# NodeJS Console Logger
A powerful and efficient JavaScript logger for NodeJS

```
npm install forbidden-node-logger
```
[![NPM Version](https://badgen.net/npm/v/forbidden-node-logger)](https://www.npmjs.com/package/forbidden-node-logger)
[![NPM Downloads](https://badgen.net/npm/dm/forbidden-node-logger)](https://www.npmjs.com/package/forbidden-node-logger)

## Getting Started

### Logger (No File Support)
```js
const NodeLogger = require("../src/index");
const Logger = new NodeLogger.Logger();
```

### Logger (File Support)
```js
const NodeLogger = require("../src/index");
const Logger = new NodeLogger.Logger({ dirPath: __dirname + "/log" });
```

### Logger Basics
```js
const NodeLogger = require("../src/index");
const Logger = new NodeLogger.Logger({ dirPath: __dirname + "/log" });

Logger.on("log", log => { /* Code */ }) // Emits when logging with any method
Logger.on("error", log => { /* Code */ }); // Emits when doing `Logger.error();`
// All log methods include an event "info", "debug" vice versa

Logger.log("Plain log");
Logger.log("&6Logger&r with &3colour");
Logger.eventLog("Log with no event emit"); // Look at "test/break.js" as why this exists

Logger.history.last(2); // Get the last 2 logs
Logger.fileHistory.getLatestLog().then(lines => Logger.eventLog(lines)); // Log an array of lines from the latest log file
```

### Avoid Unhandled Rejection
```js
const NodeLogger = require("../src/index");
const Logger = new NodeLogger.Logger({ dirPath: __dirname + "/log" });

/*
The EventEmitter will cause an unhandled rejection error
When you use Logger.error(). You need to handle the reject by not handling it
*/
Logger.on("error", () => { }); // This only applies to those who are not in need of the "error" emit

Logger.error("My Error");
```

## File Structure
```
yyyy ->
    mm ->
        dd.log
        dd-warn.log
        dd-error.log
```
### Example
```
2019 ->
    09 ->
        01.log
        01-error.log
    10 ->
        03.log
        04.log
        05.log
        06.log
        06-warn.log
        07.log
        07-error.log
2020 ->
    01 ->
        01.log
        01-error.log
    02 ->
        03.log
        04.log
        05.log
        06.log
        06-warn.log
        07.log
        07-error.log
```

## Test Scripts
In the project directory you can run the following scripts:

### `npm run log`
Will run a sample of the Logger's log methods and events\
Located at *test/log.js*

### `npm run history`
Will run a sample of Logger's history and file history\
Located at *test/history.js*

### `npm run break`
Will run a file which is designed to break Logger\
Used for educational purposes. eventLog() is to prevent this.\
Located at *test/break.js*

## Colour Codes
**PREFIX**: `&`

### Special
**RESET**: `r`\
**REVERSE**: `k`

### Format
**BOLD**: `l`\
**ITALIC**: `o`\
**UNDER**: `n`\
**STRIKE**: `m`

### Colour
**FOREGROUND**: `-`\
**BACKGROUND**: `_`\
**EXAMPLE**: `&-5`

**DARK RED**: `4`\
**BRIGHT RED**: `c`

**DARK YELLOW**: `6`\
**BRIGHT YELLOW**: `e`

**DARK GREEN**: `2`\
**BRIGHT GREEN**: `a`

**DARK CYAN**: `3`\
**BRIGHT CYAN**: `b`

**DARK BLUE**: `1`\
**BRIGHT BLUE**: `9`

**DARK PURPLE**: `5`\
**BRIGHT PURPLE**: `d`

**DARK WHITE**: `7`\
**BRIGHT WHITE**: `f`

**DARK BLACK**: `0`\
**BRIGHT BLACK**: `8`

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