std rendering of 'client_req' (http client request) field in bunyan CLI 'paul' mode (the default) output

master
Trent Mick 2012-02-08 15:27:14 -08:00
parent d53107246a
commit 62812bac31
2 changed files with 18 additions and 0 deletions

View File

@ -20,6 +20,7 @@
as the basis for tools to consume bunyan logs. It can grow indep of node-bunyan
for generating the logs.
It would take a Bunyan log record object and be expected to emit it.
- document "well-known" keys from bunyan CLI p.o.v.. Add "client_req".

View File

@ -332,6 +332,23 @@ function handleLogLine(line, opts) {
}
delete rec.req;
if (rec.client_req) {
var headers = rec.client_req.headers;
var hostHeaderLine = '';
if (rec.client_req.address) {
hostHeaderLine = 'Host: ' + rec.client_req.address;
if (rec.client_req.port)
hostHeaderLine += ':' + rec.client_req.port;
hostHeaderLine += '\n';
}
details.push(indent(format("%s %s HTTP/1.1\n%s%s", rec.client_req.method,
rec.client_req.url,
hostHeaderLine,
Object.keys(headers).map(
function (h) { return h + ': ' + headers[h]}).join('\n'))));
}
delete rec.client_req;
if (rec.res) {
var s = '';
if (rec.res.header) {