Skip to content

Commit

Permalink
[api] Remove winston logging in favor of custom events
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Apr 16, 2011
1 parent a5d88aa commit a89b397
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 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
- Include missing dependency in package.json (indexzero)

Expand Down
12 changes: 7 additions & 5 deletions lib/node-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
var util = require('util'),
http = require('http'),
events = require('events'),
winston = require('winston'),
ProxyTable = require('./proxy-table').ProxyTable,
maxSockets = 100;

Expand Down Expand Up @@ -105,19 +104,17 @@ exports.createServer = function () {

proxy = new HttpProxy(options);
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
// or response in some way, then call it.
if (callback) {
callback(req, res, proxy);
}
else if (port && host) {
winston.verbose('Proxying HTTP request to: ' + host + ':' + port);
proxy.proxyRequest(req, res, port, host);
}
else if (proxy.proxyTable) {
winston.verbose('Proxying request using proxy table');
proxy.proxyRequest(req, res);
}
else {
Expand Down Expand Up @@ -279,12 +276,17 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, buffer) {
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
// specified request to the address provided in `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);
}

Expand Down
7 changes: 1 addition & 6 deletions lib/proxy-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

var util = require('util'),
events = require('events'),
fs = require('fs'),
winston = require('winston');
fs = require('fs');

//
// ### function ProxyTable (router, silent)
Expand Down Expand Up @@ -119,8 +118,6 @@ ProxyTable.prototype.getProxyLocation = function (req) {
host = location[0],
port = location.length === 1 ? 80 : location[1];

winston.verbose('Proxy Table proxying request to: ' + host + ':' + port);

return {
port: port,
host: host
Expand All @@ -136,8 +133,6 @@ ProxyTable.prototype.getProxyLocation = function (req) {
host = location[0],
port = location.length === 1 ? 80 : location[1];

winston.verbose('Proxy Table proxying request to: ' + host + ':' + port);

return {
port: port,
host: host
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"colors": ">= 0.3.0",
"optimist": ">= 0.1.6",
"request": ">= 1.9.0",
"vows": ">= 0.5.8",
"winston": ">= 0.2.5"
"vows": ">= 0.5.8"
},
"main": "./lib/node-http-proxy",
"bin": { "node-http-proxy": "./bin/node-http-proxy" },
Expand Down

0 comments on commit a89b397

Please sign in to comment.