Giter VIP home page Giter VIP logo

churchill's Introduction

churchill

A winston express logger called churchill

Installing

npm install churchill

Running the tests

npm test

Usage

var churchill = require('churchill');
app.use(require('churchill')(winston));

Specify a log level

app.use(require('churchill')(winston, 'express'));

Using multiple loggers

var logger = new (winston.Logger).....
app.use(require('churchill').add(logger, 'express').add(logger, 'someOtherLogLevel'));

req.logger The first logger will be automatically added to req.logger This then gives you the facility to use the logger from req like so:

req.logger.log('something in winston');
req.logger.error('Oh noe!');

req.log Churchill will also add a log method to the request object, which will log to all mounted loggers:

req.log('info', 'something in winston');
req.log('error', 'OH NO!');

To disable this set reqLogger to false in the options.

Formatting

var logger = new (winston.Logger).....
app.use(require('churchill').add(logger, 'express').format(function (obj, req, res) {
  obj.somethingInteresting = req.params.moreData;
}));

Suppressing GET params from logs

var churchill = require('churchill')
churchill.options.logGetParams = false

Output

In it's simplest form a console output looks like this:

info:  status=200, method=GET, url=/, response_time=4
info:  status=304, method=GET, url=/, response_time=1
info:  status=304, method=GET, url=/, response_time=0

Examples

To run the examples go into the example dir and npm install then just node simple or node multiple to see them in action.

churchill's People

Contributors

daniel-ac-martin avatar doodlemoonch avatar easternbloc avatar keithamus avatar lennym avatar timgent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

churchill's Issues

wish: show example logging in documentation

From reading the source code, it appears this does something with logging the start and end times of requests, but that's not clear from the documentation.

It would be helpful if README.md was updated to show what some example logging looks like.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.