Skip to content

Commit a89b397

Browse files
committed
[api] Remove winston logging in favor of custom events
1 parent a5d88aa commit a89b397

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## ChangeLog for: node-http-proxy
22

3+
## Version 0.5.0 - 4/15/2011
4+
- Remove winston in favor of custom events (indexzero)
5+
6+
37
## Version 0.4.1 - 3/20/2011
48
- Include missing dependency in package.json (indexzero)
59

Diff for: lib/node-http-proxy.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
var util = require('util'),
2828
http = require('http'),
2929
events = require('events'),
30-
winston = require('winston'),
3130
ProxyTable = require('./proxy-table').ProxyTable,
3231
maxSockets = 100;
3332

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

106105
proxy = new HttpProxy(options);
107106
server = http.createServer(function (req, res) {
108-
winston.verbose('Incoming HTTP request to: ' + req.headers.host + req.url);
107+
proxy.emit('request', req, req.headers.host, req.url);
109108

110109
// If we were passed a callback to process the request
111110
// or response in some way, then call it.
112111
if (callback) {
113112
callback(req, res, proxy);
114113
}
115114
else if (port && host) {
116-
winston.verbose('Proxying HTTP request to: ' + host + ':' + port);
117115
proxy.proxyRequest(req, res, port, host);
118116
}
119117
else if (proxy.proxyTable) {
120-
winston.verbose('Proxying request using proxy table');
121118
proxy.proxyRequest(req, res);
122119
}
123120
else {
@@ -279,12 +276,17 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, buffer) {
279276
host = location.host;
280277
}
281278

279+
//
280+
// Emit the `start` event indicating that we have begun the proxy operation.
281+
//
282+
this.emit('start', req, res, host, port);
283+
282284
//
283285
// If forwarding is enabled for this instance, foward proxy the
284286
// specified request to the address provided in `this.options.forward`
285287
//
286288
if (this.options.forward) {
287-
winston.verbose('Forwarding HTTP request to: ' + this.options.forward.host + ':' + this.options.forward.port);
289+
this.emit('forward', req, res, this.options.forward.host, this.options.forward.port);
288290
this._forwardRequest(req);
289291
}
290292

Diff for: lib/proxy-table.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
var util = require('util'),
2828
events = require('events'),
29-
fs = require('fs'),
30-
winston = require('winston');
29+
fs = require('fs');
3130

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

122-
winston.verbose('Proxy Table proxying request to: ' + host + ':' + port);
123-
124121
return {
125122
port: port,
126123
host: host
@@ -136,8 +133,6 @@ ProxyTable.prototype.getProxyLocation = function (req) {
136133
host = location[0],
137134
port = location.length === 1 ? 80 : location[1];
138135

139-
winston.verbose('Proxy Table proxying request to: ' + host + ':' + port);
140-
141136
return {
142137
port: port,
143138
host: host

Diff for: package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
"colors": ">= 0.3.0",
1818
"optimist": ">= 0.1.6",
1919
"request": ">= 1.9.0",
20-
"vows": ">= 0.5.8",
21-
"winston": ">= 0.2.5"
20+
"vows": ">= 0.5.8"
2221
},
2322
"main": "./lib/node-http-proxy",
2423
"bin": { "node-http-proxy": "./bin/node-http-proxy" },

0 commit comments

Comments
 (0)