index.js 938 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. const VERSION = "1.0.4";
  4. /**
  5. * @param octokit Octokit instance
  6. * @param options Options passed to Octokit constructor
  7. */
  8. function requestLog(octokit) {
  9. octokit.hook.wrap("request", (request, options) => {
  10. octokit.log.debug("request", options);
  11. const start = Date.now();
  12. const requestOptions = octokit.request.endpoint.parse(options);
  13. const path = requestOptions.url.replace(options.baseUrl, "");
  14. return request(options).then(response => {
  15. octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`);
  16. return response;
  17. }).catch(error => {
  18. octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`);
  19. throw error;
  20. });
  21. });
  22. }
  23. requestLog.VERSION = VERSION;
  24. exports.requestLog = requestLog;
  25. //# sourceMappingURL=index.js.map