Skip to content

Commit

Permalink
Reduce default log line length to 80 characters & trim messages in fe…
Browse files Browse the repository at this point in the history
…w other places
  • Loading branch information
dhruvbird committed May 15, 2012
1 parent ca39ab0 commit 24f456d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/dutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,12 @@ function replace_promise(s, victim, replacement) {
});
}

var TRIM_DEFAULT_LENGTH = 80;

function trim_promise(s, len) {
return new ToStringPromise(function() {
len = len || 1024;
len = len < 0 || len > 1024 ? 1024 : len;
len = len || TRIM_DEFAULT_LENGTH;
len = len < 0 || len > TRIM_DEFAULT_LENGTH ? TRIM_DEFAULT_LENGTH : len;
if (typeof(s) !== "string") {
s = String(s);
}
Expand Down
2 changes: 1 addition & 1 deletion src/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function HTTPServer(port, host, stat_func, bosh_request_handler, http_error_hand
} else {
var body = parse_request(req_parts);
if (body) {
log.debug("RECD: %s", body);
log.debug("RECD: %s", dutil.replace_promise(dutil.trim_promise(body), '\n', ' '));
res.request_headers = req.headers;
bosh_request_handler(res, body);
}
Expand Down
2 changes: 1 addition & 1 deletion src/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Response.prototype = {
this._res.setHeader("Content-Length", Buffer.byteLength(msg, 'utf8'));
this._res.writeHead(200, this._options.HTTP_POST_RESPONSE_HEADERS);
this._res.end(msg);
log.debug("%s SENT(%s): %s", this._sid, this.rid, msg);
log.debug("%s SENT(%s): %s", this._sid, this.rid, dutil.replace_promise(dutil.trim_promise(msg), '\n', ' '));
},

// If a client closes a connection and a response to that HTTP request
Expand Down

0 comments on commit 24f456d

Please sign in to comment.