winston-restify

0.0.2 • Public • Published

winston-restify

Another transport to sending logs with winston. Inspired by winston-endpoint

standard travis Code Coverage npm

Installation:

npm install winston-restify --save

Note:

Requires Node >8.0.0.

API Options:

Key Description
level logging-levels
silent setting to true will turn the console transport off (default: false)
dispatch setting to false will disable log shipping (default: true)
client api-options
basicAuth description
debug print responses status
prepend sends the level and message to request (default: { level: true, message: true })

Meta Options:

Key Description
method HTTP method (default: post)
options description
path endpoint api (default: '/')
data object for sending, supported in POST methods, PUT (default: {})

Example:

This example is available here as well.

'use strict'
 
const restify = require('restify')
const winston = require('winston')
const winstonRestify = require('winston-restify')
 
winston
  // HTTP transport included to winston
  .add(
    winstonRestify, {
      silent: true,
      dispatch: true,
      debug: true,
      client: {
        url: 'http://localhost:8080/logger'
      }
    }
  )
  // remove transport from the logger to terminal
  .remove(winston.transports.Console)
 
const server = restify.createServer()
 
server.get('/', function (req, res, next) {
  winston.info('sending_logger', {
    method: 'get',
    path: '/logger'
  })
  res.send(200, { info: 'see your terminal!!' })
  next()
})
 
server.get('/logger', function (req, res, next) {
  console.log('hello logger!!!!')
  next()
})
 
server.listen(8080, function () {
  console.log('listening on http://localhost:8080/')
})
 
 

Tests

npm test

License

MIT

Copyright (c) 2018-present

Package Sidebar

Install

npm i winston-restify

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

8.29 kB

Total Files

7

Last publish

Collaborators

  • carvalho.viniciusluiz