mirror of
https://github.com/actions/github-script.git
synced 2026-04-07 22:50:04 +00:00
Add @octokit/plugin-request-log, to produce debug output for requests
Without this plugin, the debug setting is, effectively, meaningless as none of the existing plugins produce log output. The plugin writes the request options to octokit.log.debug, and response times as *method path - status in ...ms* to octokit.log.info.
This commit is contained in:
parent
454e5d7e69
commit
d415b06b8c
5 changed files with 83 additions and 4 deletions
46
dist/index.js
vendored
46
dist/index.js
vendored
|
|
@ -6542,6 +6542,45 @@ exports.paginatingEndpoints = paginatingEndpoints;
|
|||
//# sourceMappingURL=index.js.map
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8883:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
var __webpack_unused_export__;
|
||||
|
||||
|
||||
__webpack_unused_export__ = ({ value: true });
|
||||
|
||||
const VERSION = "1.0.4";
|
||||
|
||||
/**
|
||||
* @param octokit Octokit instance
|
||||
* @param options Options passed to Octokit constructor
|
||||
*/
|
||||
|
||||
function requestLog(octokit) {
|
||||
octokit.hook.wrap("request", (request, options) => {
|
||||
octokit.log.debug("request", options);
|
||||
const start = Date.now();
|
||||
const requestOptions = octokit.request.endpoint.parse(options);
|
||||
const path = requestOptions.url.replace(options.baseUrl, "");
|
||||
return request(options).then(response => {
|
||||
octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`);
|
||||
return response;
|
||||
}).catch(error => {
|
||||
octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`);
|
||||
throw error;
|
||||
});
|
||||
});
|
||||
}
|
||||
requestLog.VERSION = VERSION;
|
||||
|
||||
exports.g = requestLog;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6298:
|
||||
|
|
@ -15091,8 +15130,10 @@ var utils = __nccwpck_require__(3030);
|
|||
var glob = __nccwpck_require__(8090);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
|
||||
var io = __nccwpck_require__(7436);
|
||||
// EXTERNAL MODULE: ./node_modules/@octokit/plugin-request-log/dist-node/index.js
|
||||
var dist_node = __nccwpck_require__(8883);
|
||||
// EXTERNAL MODULE: ./node_modules/@octokit/plugin-retry/dist-node/index.js
|
||||
var dist_node = __nccwpck_require__(6298);
|
||||
var plugin_retry_dist_node = __nccwpck_require__(6298);
|
||||
// EXTERNAL MODULE: ./node_modules/node-fetch/lib/index.js
|
||||
var lib = __nccwpck_require__(467);
|
||||
var lib_default = /*#__PURE__*/__nccwpck_require__.n(lib);
|
||||
|
|
@ -15171,6 +15212,7 @@ const wrapRequire = new Proxy(require, {
|
|||
|
||||
|
||||
|
||||
|
||||
process.on('unhandledRejection', handleError);
|
||||
main().catch(handleError);
|
||||
async function main() {
|
||||
|
|
@ -15192,7 +15234,7 @@ async function main() {
|
|||
opts.previews = previews.split(',');
|
||||
if (requestOpts)
|
||||
opts.request = requestOpts;
|
||||
const github = (0,lib_github.getOctokit)(token, opts, dist_node/* retry */.XD);
|
||||
const github = (0,lib_github.getOctokit)(token, opts, plugin_retry_dist_node/* retry */.XD, dist_node/* requestLog */.g);
|
||||
const script = core.getInput('script', { required: true });
|
||||
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
|
||||
const result = await callAsyncFunction({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue