# @node-lightning/logger

> Logging tool for Node-Lightning applications

Latest version **0.28.0** (published 2022-11-07) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.28.0 |
| Published | 2022-11-07 |
| First published | 2020-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 147.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 137 |
| Author | Brian Mancini |
| Maintainers | bmancini55 |
| Keywords | lightning-network, logging |

## Links

- npm: https://www.npmjs.com/package/@node-lightning/logger
- Repository: https://github.com/altangent/node-lightning
- Homepage: https://github.com/altangent/node-lightning/tree/master/packages/logger
- Issues: https://github.com/altangent/node-lightning/issues
- npm.io page: https://npm.io/package/@node-lightning/logger

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.28.0 (latest) — 2022-11-07
- 0.27.4 — 2022-09-16
- 0.27.2 — 2022-09-16
- 0.27.0 — 2022-01-10
- 0.26.1 — 2021-10-06
- 0.26.0 — 2021-10-06
- 0.25.0 — 2021-10-04
- 0.24.1 — 2021-09-27
- 0.24.0 — 2021-09-15
- 0.23.0 — 2021-09-13
- 0.23.0-alpha.0 — 2021-07-29
- 0.22.1 — 2021-04-30
- 0.22.0 — 2021-04-09
- 0.21.1 — 2021-02-18
- 0.21.0 — 2021-02-18
- … 3 more at https://npm.io/package/@node-lightning/logger/versions

## README

# Node-Lightning Logger

Logger for Node-Lightning modules that supports multi-transport, multi-area+instance logging using standard `util.format` sprintf value formatting.

### Getting Started

```bash
npm install @node-lightning/logger
```

To use the module you will need to create an area logger and include an optional instance identifier:

```javascript
const { manager } = require("@node-lightning/logger");

const area = "TEST";
const instanceId = "12345678";
const log = manager.create(area, instanceId);
```

Then you can write `debug`, `info`, `warn`, and `error` messages by passing a message an a variadic number of values. You can pass text, values, sprintf syle strings, or a string and a list of values that will be appended to the end of the message.

```javascript
log.debug("test");
log.info("hello");
log.warn("i'm warning you");
log.error("something went bad");
log.error(new Error("booooom"));
log.info("some stuff %j", { ok: true, foo: "bar" });
log.info("some values", 1, 2, 3, 4);
log.info("using %s formatting", "sprintf");
```

The above message should look similar to:

```
2019-07-22T13:28:37.854Z [DBG] TEST 12345678: test
2019-07-22T13:28:37.855Z [INF] TEST 12345678: hello
2019-07-22T13:28:37.855Z [WRN] TEST 12345678: i'm warning you
2019-07-22T13:28:37.855Z [ERR] TEST 12345678: something went bad
2019-07-22T13:28:37.856Z [ERR] TEST 12345678: Error: booooom
    at Object.<anonymous> (/code/go/src/github.com/altangent/node-lightning/packages/logger/test.js:9:11)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
2019-07-22T13:28:37.856Z [INF] TEST 12345678: some stuff {"ok":true,"foo":"bar"}
2019-07-22T13:28:37.856Z [INF] TEST 12345678: some values 1 2 3 4
2019-07-22T13:28:37.856Z [INF] TEST 12345678: using sprintf formatting
```

### Output

The default instance of the logger will output to:

-   `console`
-   `node-lightning.log` file located at the root of the application runtime

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