winston-restify
v0.0.2
Published
Another transport to sending logs with winston.
Downloads
12
Maintainers
Readme
winston-restify
Another transport to sending logs with winston. Inspired by winston-endpoint
Installation:
npm install winston-restify --saveNote:
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 testLicense
Copyright (c) 2018-present

