# fast-node-logger

> fast file logger base on pino

Latest version **3.0.4** (published 2022-10-24) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.4 |
| Published | 2022-10-24 |
| First published | 2019-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 61.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Saeid Ostad |
| Maintainers | saostad |
| Keywords | node, logger, fast, rotator, pino, file, log |

## Links

- npm: https://www.npmjs.com/package/fast-node-logger
- Repository: https://github.com/saostad/fast-node-logger
- Homepage: https://github.com/saostad/fast-node-logger#readme
- Issues: https://github.com/saostad/fast-node-logger/issues
- npm.io page: https://npm.io/package/fast-node-logger

## Dependencies (3)

- [pino](https://npm.io/package/pino.md) ^8.7.0
- [rimraf](https://npm.io/package/rimraf.md) ^3.0.2
- [pino-pretty](https://npm.io/package/pino-pretty.md) ^9.1.1

## 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

- 3.0.4 (latest) — 2022-10-24
- 3.0.3 — 2022-08-17
- 3.0.2 — 2022-08-16
- 3.0.1 — 2022-08-15
- 3.0.0 — 2022-07-19
- 3.0.0-beta05 — 2022-07-19
- 3.0.0-beta04 — 2022-07-19
- 3.0.0-beta03 — 2022-07-19
- 3.0.0-beta02 — 2022-07-19
- 3.0.0-beta01 — 2022-07-19
- 2.0.2 — 2022-07-19
- 2.0.1 — 2022-07-19
- 2.0.0 — 2021-06-25
- 1.4.13 — 2021-04-27
- 1.4.12 — 2021-02-27
- … 29 more at https://npm.io/package/fast-node-logger/versions

## README

### An opinionated file logger with limited rotation policy options, base on [pino](https://www.npmjs.com/package/pino).

this package provides:

- quick start with default configuration.
- an instance of [pino](https://www.npmjs.com/package/pino) logger.
- flexibility of pino with options and prettify the output.
- create log files in `logs` directory of root project directory.
- delete old log files.
- type safe with typescript.

## Notice:

This is an opinionated package that limit the flexibility of awesome [pino](https://www.npmjs.com/package/pino) package. if you need full functionality please use original package.

## Quick Start

```js
import { createLogger } from "fast-node-logger";

const logger = await createLogger();
logger.info(`Logger is Ready!`);
```

## VSCode extension

You can use the complimentary extension for VSCode [writelog-snippets](https://marketplace.visualstudio.com/items?itemName=saostad.writelog-snippets).

## Customization

```js
const options: Options = {
  logDir: "./my-logs",
  retentionTime: 604800, // for 7 days
};
await createLogger(options);
```

### Documentations

[Documentations website](https://saostad.github.io/fast-node-logger/)

### use pino original options [Pino Docs](https://github.com/pinojs/pino/blob/master/docs/api.md#options)

```js
import { createLogger, Options } from "fast-node-logger";

const options: Options = {
  level: "trace",
};

const logger = await createLogger(options);
```

### CreateLogger(options)

returns an instance of pino

```js
import { createLogger } from "fast-node-logger";

const logger = await createLogger();

logger.info(`Logger is Ready!`);
```

### writeLog(message, {stdout: false})

a shortcut for `logger.info(message)` with ability to additionally print to console with second parameter `{stdout: true}`

```js
import { writeLog, createLogger, Options } from "fast-node-logger";

await createLogger();

writeLog(`logger is created!`, { stdout: true, level: "trace" });
```

### TODO:

- [ ] add [recommended log rotation](https://github.com/pinojs/pino/blob/master/docs/help.md#log-rotation)
- [ ] add ability to integrate with cloud log services (e.g. [sentry](https://sentry.io))

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