@fusedb/logger
Version:
A FUSE middleware to handle logging.
105 lines (74 loc) โข 2.56 kB
Markdown
# ๐งฉ FUSE Middleware: Logger
> A [FUSE](https://github.com/Fast-Unified-Storage-Engine/FUSE) middleware that provides logging with support for Winston, Pino, etc.


[](./LICENSE)

## ๐ฆ Installation
```bash
npm install @fusedb/core
npm install @fusedb/logger
```
## ๐ Usage
#### Console:
```js
const FUSE = require("@fusedb/core");
const JSONDriver = require("@fusedb/json");
const Logger = require("@fusedb/logger");
const db = new FUSE({
driver: new JSONDriver({ path: "./data/db.json" }),
middleware: [new Logger()],
});
(async () => {
await db.set("name", "Fuse");
await db.get("name");
})();
```
#### Winston:
```js
const FUSE = require("@fusedb/core");
const JSONDriver = require("@fusedb/json");
const Logger = require("@fusedb/logger");
const winston = require("winston");
const customLogger = winston.createLogger({
level: "info",
transports: [new winston.transports.Console()],
});
const db = new FUSE({
driver: new JSONDriver({ path: "./data/db.json" }),
middleware: [
new Logger({ mode: "custom", logger: customLogger })
],
});
(async () => {
await db.set("name", "Fuse");
await db.get("name");
})();
```
## โ๏ธ Options
| Option | Type | Description |
| ------ | ----- | --------------------------------------------- |
| `mode` | `string` | *Set to custom or console* |
| `logger` | `object` | *Logger instance (e.g. winston or pino)* |
| `includeValues` | `object` | *Log full values* |
## โ
Features
* โ
Works with any FUSE driver
* โ
Compatible with Winston, Pino, etc.
## ๐ Related
* [FUSE Core](https://www.npmjs.com/package/@fusedb/core)
* [FUSE Github](https://github.com/Fast-Unified-Storage-Engine/FUSE)
* [Middleware API Specification](https://github.com/Fast-Unified-Storage-Engine/FUSE/blob/main/MIDDLEWARE_SPECIFICATION.md)
## ๐ค Contributing
Want to make your own middleware?
* Name it like: `fusedb-<name>` or `@your-org/fusedb-<name>`
* Follow the [Middleware Guidelines](https://github.com/fusedb/.github/blob/main/CONTRIBUTING.md)
Feel free to share your plugin with the community!
## ๐งพ License
Licensed under the [Apache-2.0](./LICENSE).