Skip to content

Commit

Permalink
fix(websocket log): clear logJson
Browse files Browse the repository at this point in the history
  • Loading branch information
tarotlwei committed Jul 18, 2018
1 parent f280461 commit 2f94faa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/tsw/util/auto-report/logReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ function reportLog() {
res._body = Buffer.from(format.formatBuffer(res._body));
}

logJson = logJson || logger.getJson() || {};
logJson = logJson || logger.getJson(isWebSocket) || {};
logJson.curr = {
protocol: 'HTTP',
host: req.headers.host,
Expand Down
6 changes: 5 additions & 1 deletion bin/tsw/util/logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Logger.prototype = {
contextMod.currentContext().log = null;
},

getJson: function() {
getJson: function(cleared) {
const log = this.getLog();
let json = {
curr: {},
Expand All @@ -97,6 +97,10 @@ Logger.prototype = {
log.json = json;
}

if (cleared) {
log.json = null;
}

return json;
},

Expand Down

0 comments on commit 2f94faa

Please sign in to comment.