Tim Starling has uploaded a new change for review.
https://gerrit.wikimedia.org/r/245604
Change subject: Improve ApiRequest logging
......................................................................
Improve ApiRequest logging
* Introduce apirequest trace channel
* Log request options instead of this.toString(), the latter just gives
"[object Object]".
Change-Id: Ied1a598fca8c07a00a409a2aa184fcd6de68f879
---
M lib/ParsoidLogger.js
M lib/mediawiki.ApiRequest.js
M lib/mediawiki.Util.js
3 files changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/04/245604/1
diff --git a/lib/ParsoidLogger.js b/lib/ParsoidLogger.js
index d7dc9af..25f4974 100644
--- a/lib/ParsoidLogger.js
+++ b/lib/ParsoidLogger.js
@@ -156,6 +156,7 @@
"trace/domdiff": "[DOM-DIFF]",
"trace/wt-escape": "[wt-esc]",
"trace/batcher": "[batcher]",
+ "trace/apirequest": "[ApiRequest]",
};
ParsoidLogger.prototype._defaultTracerBackend = function(logData, cb) {
diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index 4476ec9..a006755 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -258,7 +258,8 @@
options.headers['X-Forwarded-Proto'] = 'https';
}
}
- this.env.dp("Starting HTTP request", this.toString());
+ this.env.dp("Starting HTTP request: ", options);
+ this.trace(options);
return request(options, callback);
};
@@ -325,6 +326,7 @@
var self = this;
if (error) {
+ this.trace("Received error:", error);
this.env.log('warning/api' + (error.code ? ("/" +
error.code).toLowerCase() : ''),
'Failed API request,', {
"error": error,
@@ -344,8 +346,10 @@
this._handleBody(dnee, '{}');
}
} else if (response.statusCode === 200) {
+ this.trace("Received HTTP 200, ", body.length, "bytes");
this._handleBody(null, body);
} else {
+ this.trace("Received HTTP", response.statusCode, ": ", body);
if (response.statusCode === 412) {
this.env.log("info", "Cache MISS:",
response.request.href);
} else {
@@ -391,6 +395,10 @@
this._handleJSON(error, data);
};
+ApiRequest.prototype.trace = function() {
+ this.env.log.apply(null,
["trace/apirequest"].concat(Array.prototype.slice.call(arguments)));
+};
+
/**
* @class
* @extends ApiRequest
diff --git a/lib/mediawiki.Util.js b/lib/mediawiki.Util.js
index f210223..4c0bfc3 100644
--- a/lib/mediawiki.Util.js
+++ b/lib/mediawiki.Util.js
@@ -134,6 +134,7 @@
" * domdiff : trace actions of the DOM diffing code",
" * wt-escape : debug wikitext-escaping",
" * batcher : trace API batch aggregation and
dispatch",
+ " * apirequest: trace all API requests",
"",
"--debug enables tracing of all the above phases except
Token Transform Managers",
"",
--
To view, visit https://gerrit.wikimedia.org/r/245604
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied1a598fca8c07a00a409a2aa184fcd6de68f879
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits