Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

Bambil/happy-winston

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

happy-winston

npm-downloads npm-license npm-version

Introdcution

A logging server built on top of winston and hapi.js, capable of receiving and querying logs.

Services

Each winstond server can utilize up to 2 different services, which leverage the main capabilities of a winston transport.

  • collect - log collection
  • query - querying logs

Usage

Creating a winstond server

const happyWinston = require('happy-winston')

const server = new happyWinston.Winstond()
server.add(happyWinston.transports.Console, {
  colorize: true,
  timestamp: true,
  stringify: true,
  prettyPrint: true
})
server.add(happyWinston.transports.File, {
  filename: 'newbie.log'
})
server.listen()

server.on('listening', () => {
  console.log('server starts on 127.0.0.1:9003')
})

Communicating with a winstond server

const winston = require('winston')

winston.add(winston.transports.Http, {
  host: '127.0.0.1',
  port: 9003
})

winston.log('info', 'hello')
winston.log('info', 2)
winston.query({
  from: new Date() - 24 * 60 * 60 * 1000,
  until: new Date(),
  limit: 10,
  start: 0,
  order: 'desc'
}, (err, results) => {
  if (err) {
    console.log(err)
  } else {
    if (results.http.file) {
      for (let r of results.http.file) {
        console.log(r)
      }
    }
  }
})

Backends

winstond supports http backend.

Installation

$ npm install happy-winston

Releases

No releases published

Packages

No packages published