1.2.2 • Published 2 years ago

fastify-log v1.2.2

Weekly downloads
256
License
MIT
Repository
github
Last release
2 years ago

fastify-log

Build Status npm version Greenkeeper badge

A terminal logger plugin for Fastify.

Features

  • Displays time.
  • Colorful outputs.
  • Debug level support.

Install

npm install fastify-log

Usage

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:

ScreenShot

API

options

OptionDescriptionTypeDefault
allInOneIf true, you should use fastify.logger.info/warn/error instead of fastify.info/warn/error.Booleanfalse
timeIf false, current time will not show.Booleantrue
timeFormatDisplay format for the time.String'HH:mm:ss'
levelDetermine debug level. If level > 1, info hides. If level > 2, only error shows. If level > 3, all hide.Number1
infoColor for info messages.String'#ffffff'
warnColor for warning messages.String'#ffa500'
errorColor for error messages.String'#dc143c'
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:

License

MIT