Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simenandre/fastify-frontend-logger
A Fastify plugin for receiving browser logs to a server
https://github.com/simenandre/fastify-frontend-logger
fastify fastify-plugin logger typescript
Last synced: 27 days ago
JSON representation
A Fastify plugin for receiving browser logs to a server
- Host: GitHub
- URL: https://github.com/simenandre/fastify-frontend-logger
- Owner: simenandre
- License: apache-2.0
- Created: 2022-07-13T13:34:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-13T16:17:08.000Z (about 2 months ago)
- Last Synced: 2024-12-05T08:44:40.129Z (about 1 month ago)
- Topics: fastify, fastify-plugin, logger, typescript
- Language: TypeScript
- Homepage:
- Size: 298 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# fastify-frontend-logger
A Fastify plugin for receiving browser logs to a server
## Features
- Very customizable
- Logger objects like `pino`
- Appends `"type": "frontend-logger"` to every log.## Quickstart
```bash
yarn add fastify-frontend-logger
``````typescript
import fastify from 'fastify';
import { frontendLoggerPlugin } from 'fastify-frontend-logger';const server = fastify();
server.register(frontendLoggerPlugin);
```The frontend logger adds a method to your server at `/logger`. This consumes a
default logger object:```json
[
{
"msg": "Hello world",
"level": 30,
"time": 1483531681798,
"ctx": {
"browser": "Firefox"
},
"payload": {
"users": ["cobraz"]
}
}
]
```**Note**: You can change how the logger object is by setting `bodySchema` in the
plugin options.## Options
- `path` can be used to change where the logger is served (defaults to
`/logger`).
- `bodySchema` can be used to change the validation schema.
- `preHandler` can be used to run code before passing to logs (e.g.
authentication)
- `loggerOptions` the plugin adds a logger child, with this option you can set
your own.