Commit a89b3976 authored by indexzero's avatar indexzero

[api] Remove winston logging in favor of custom events

parent a5d88aaa
## ChangeLog for: node-http-proxy ## ChangeLog for: node-http-proxy
## Version 0.5.0 - 4/15/2011
- Remove winston in favor of custom events (indexzero)
## Version 0.4.1 - 3/20/2011 ## Version 0.4.1 - 3/20/2011
- Include missing dependency in package.json (indexzero) - Include missing dependency in package.json (indexzero)
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
var util = require('util'), var util = require('util'),
http = require('http'), http = require('http'),
events = require('events'), events = require('events'),
winston = require('winston'),
ProxyTable = require('./proxy-table').ProxyTable, ProxyTable = require('./proxy-table').ProxyTable,
maxSockets = 100; maxSockets = 100;
...@@ -105,7 +104,7 @@ exports.createServer = function () { ...@@ -105,7 +104,7 @@ exports.createServer = function () {
proxy = new HttpProxy(options); proxy = new HttpProxy(options);
server = http.createServer(function (req, res) { server = http.createServer(function (req, res) {
winston.verbose('Incoming HTTP request to: ' + req.headers.host + req.url); proxy.emit('request', req, req.headers.host, req.url);
// If we were passed a callback to process the request // If we were passed a callback to process the request
// or response in some way, then call it. // or response in some way, then call it.
...@@ -113,11 +112,9 @@ exports.createServer = function () { ...@@ -113,11 +112,9 @@ exports.createServer = function () {
callback(req, res, proxy); callback(req, res, proxy);
} }
else if (port && host) { else if (port && host) {
winston.verbose('Proxying HTTP request to: ' + host + ':' + port);
proxy.proxyRequest(req, res, port, host); proxy.proxyRequest(req, res, port, host);
} }
else if (proxy.proxyTable) { else if (proxy.proxyTable) {
winston.verbose('Proxying request using proxy table');
proxy.proxyRequest(req, res); proxy.proxyRequest(req, res);
} }
else { else {
...@@ -279,12 +276,17 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, buffer) { ...@@ -279,12 +276,17 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, buffer) {
host = location.host; host = location.host;
} }
//
// Emit the `start` event indicating that we have begun the proxy operation.
//
this.emit('start', req, res, host, port);
// //
// If forwarding is enabled for this instance, foward proxy the // If forwarding is enabled for this instance, foward proxy the
// specified request to the address provided in `this.options.forward` // specified request to the address provided in `this.options.forward`
// //
if (this.options.forward) { if (this.options.forward) {
winston.verbose('Forwarding HTTP request to: ' + this.options.forward.host + ':' + this.options.forward.port); this.emit('forward', req, res, this.options.forward.host, this.options.forward.port);
this._forwardRequest(req); this._forwardRequest(req);
} }
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
var util = require('util'), var util = require('util'),
events = require('events'), events = require('events'),
fs = require('fs'), fs = require('fs');
winston = require('winston');
// //
// ### function ProxyTable (router, silent) // ### function ProxyTable (router, silent)
...@@ -119,8 +118,6 @@ ProxyTable.prototype.getProxyLocation = function (req) { ...@@ -119,8 +118,6 @@ ProxyTable.prototype.getProxyLocation = function (req) {
host = location[0], host = location[0],
port = location.length === 1 ? 80 : location[1]; port = location.length === 1 ? 80 : location[1];
winston.verbose('Proxy Table proxying request to: ' + host + ':' + port);
return { return {
port: port, port: port,
host: host host: host
...@@ -136,8 +133,6 @@ ProxyTable.prototype.getProxyLocation = function (req) { ...@@ -136,8 +133,6 @@ ProxyTable.prototype.getProxyLocation = function (req) {
host = location[0], host = location[0],
port = location.length === 1 ? 80 : location[1]; port = location.length === 1 ? 80 : location[1];
winston.verbose('Proxy Table proxying request to: ' + host + ':' + port);
return { return {
port: port, port: port,
host: host host: host
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
"colors": ">= 0.3.0", "colors": ">= 0.3.0",
"optimist": ">= 0.1.6", "optimist": ">= 0.1.6",
"request": ">= 1.9.0", "request": ">= 1.9.0",
"vows": ">= 0.5.8", "vows": ">= 0.5.8"
"winston": ">= 0.2.5"
}, },
"main": "./lib/node-http-proxy", "main": "./lib/node-http-proxy",
"bin": { "node-http-proxy": "./bin/node-http-proxy" }, "bin": { "node-http-proxy": "./bin/node-http-proxy" },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment