Created
August 15, 2011 21:41
-
-
Save indexzero/1147936 to your computer and use it in GitHub Desktop.
A simple winston script to log query string params.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
static = require('node-static'), | |
qs = require('querystring'), | |
winston = require('winston'), | |
MongoDB = require('winston-mongodb').MongoDB, | |
url = require('url'); | |
var file = new(static.Server)('./public'); | |
winston.use(MongoDB, { | |
// | |
// I forget the options, read the docs: https://github.com/indexzero/winston-mongodb | |
// | |
}); | |
http.createServer(function (req, res) { | |
var parts = url.parse(req.url), | |
params = qs.parse(parts); | |
// | |
// for `foo.png?x=1&y=2 | |
// | |
// params = { x: 1, y: 2 } | |
// | |
winston.info('MESSAGE', params); | |
req.on('end', function () { | |
// | |
// Serve the file | |
// | |
file.serve(req, res); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment