Skip to content

Commit dbb2464

Browse files
committed
Add http method to output
1 parent 5397216 commit dbb2464

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ function time(start) {
2222

2323
function defaultHandler(request, options, cb) {
2424
var url = (typeof options === 'string' ? urlParse(options) : options).href;
25+
var method = '[' + options.method + ']';
26+
var signature = method + ' ' + url;
2527
var start = new Date();
2628

27-
setImmediate(console.log, chalk.gray(' → ' + url));
29+
setImmediate(console.log, chalk.gray(' → ' + signature));
2830

2931
return request(options, cb)
3032
.on('response', function (response) {
3133
var status = response.statusCode;
3234
var s = status / 100 | 0;
33-
console.log(' ' + chalk[colorCodes[s]](status) + ' ← ' + url + ' ' + chalk.gray(time(start)));
35+
console.log(' ' + chalk[colorCodes[s]](status) + ' ← ' + signature + ' ' + chalk.gray(time(start)));
3436
})
3537
.on('error', function (err) {
36-
console.log(' ' + chalk.red('xxx') + ' ← ' + url + ' ' + chalk.red(err.message));
38+
console.log(' ' + chalk.red('xxx') + ' ← ' + signature + ' ' + chalk.red(err.message));
3739
});
3840
}
3941

0 commit comments

Comments
 (0)