Skip to content

Commit

Permalink
adding logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Dec 28, 2011
1 parent c99c809 commit a1134d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ var http = require('http')
, CookieJar = require('./vendor/cookie/jar')
, cookieJar = new CookieJar
;

if (process.logging) {
var log = process.logging('request')
}

try {
https = require('https')
Expand Down Expand Up @@ -326,7 +330,7 @@ Request.prototype.request = function () {
self.start = function () {
self._started = true
self.method = self.method || 'GET'

if (log) log('%method %uri', self)
self.req = self.httpModule.request(self, function (response) {
self.response = response
response.request = self
Expand Down Expand Up @@ -379,6 +383,7 @@ Request.prototype.request = function () {
if (self.headers) {
delete self.headers.host
}
if (log) log('Redirect to %uri', self)
request(self, self.callback)
return // Ignore the rest of the response
} else {
Expand Down Expand Up @@ -427,6 +432,7 @@ Request.prototype.request = function () {
})
response.on("close", function () {self.emit("close")})

if (log) log('Response %statusCode', response)
self.emit('response', response)

if (self.onResponse) {
Expand Down

0 comments on commit a1134d8

Please sign in to comment.