https://github.com/fralonra/fastify-log
Colorful terminal logger for Fastify.
https://github.com/fralonra/fastify-log
fastify fastify-plugin logger
Last synced: about 2 months ago
JSON representation
Colorful terminal logger for Fastify.
- Host: GitHub
- URL: https://github.com/fralonra/fastify-log
- Owner: fralonra
- License: mit
- Created: 2018-03-27T15:53:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-08T04:31:53.000Z (almost 3 years ago)
- Last Synced: 2025-03-09T09:03:23.602Z (2 months ago)
- Topics: fastify, fastify-plugin, logger
- Language: JavaScript
- Size: 85 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastify-log
[](https://travis-ci.com/fralonra/fastify-log)
[](https://www.npmjs.com/package/fastify-log) [](https://greenkeeper.io/)A terminal logger plugin for [Fastify](fastify.io).
## Features
* Displays time.
* Colorful outputs.
* Debug level support.## Install
```bash
npm install fastify-log
```## Usage
```javascript
const fastify = require('fastify')();
fastify.register(require('fastify-log')); // Or fastify.register(require('fastify-log'), { options } );const port = 3000;
fastify.listen(port, (err) => {
if (err) fastify.error(err);
fastify.warn('this is a waring text');
// Pass in multiple arguments
fastify.info('server listening on', port);
});
```The above code will output the following in your console, where the time is your system's current time:

### API
#### options
| Option | Description | Type | Default |
| --- | --- | --- | --- |
| allInOne | If true, you should use `fastify.logger.info/warn/error` instead of `fastify.info/warn/error`. | Boolean | false |
| time | If false, current time will not show. | Boolean | true |
| timeFormat | Display format for the time. | String | 'HH:mm:ss' |
| level | Determine debug level. If level > 1, info hides. If level > 2, only error shows. If level > 3, all hide. | Number | 1 |
| info | Color for info messages. | String | '#ffffff' |
| warn | Color for warning messages. | String | '#ffa500' |
| error | Color for error messages. | String | '#dc143c' |```javascript
const fastify = require('fastify')();
fastify.register(require('fastify-log'), { options } );
```### Alternative
`fastify-log` is quite a simple plugin, and here is a list of other tools you can turn to:
* [pino-colada](https://github.com/lrlna/pino-colada/)### License
[MIT](https://github.com/fralonra/fastify-log/blob/master/LICENSE)