Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created August 15, 2011 21:41
Show Gist options
  • Save indexzero/1147936 to your computer and use it in GitHub Desktop.
Save indexzero/1147936 to your computer and use it in GitHub Desktop.
A simple winston script to log query string params.
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