@octokit/plugin-request-log
v5.3.1
Published
Log all requests and request errors
Downloads
27,415,461
Readme
plugin-request-log.js
Log all requests and request errors
Usage
Load @octokit/plugin-request-log
and @octokit/core
(or core-compatible module) directly from esm.sh
<script type="module">
import { Octokit } from "https://esm.sh/@octokit/core";
import { requestLog } from "https://esm.sh/@octokit/plugin-request-log";
</script>
Install with npm install @octokit/core @octokit/plugin-request-log
. Optionally replace @octokit/core
with a core-compatible module
import { Octokit } from "@octokit/core";
import { requestLog } from "@octokit/plugin-request-log";
[!IMPORTANT] As we use conditional exports, you will need to adapt your
tsconfig.json
by setting"moduleResolution": "node16", "module": "node16"
.See the TypeScript docs on package.json "exports". See this helpful guide on transitioning to ESM from @sindresorhus
const MyOctokit = Octokit.plugin(requestLog);
const octokit = new MyOctokit({ auth: "secret123" });
octokit.request("GET /");
// logs "GET / - 200 in 123ms
octokit.request("GET /oops");
// logs "GET / - 404 in 123ms
In order to log all request options, the log.debug
option needs to be set. We recommend the console-log-level package for a configurable log level
import consoleLogLevel from "console-log-level";
const octokit = new MyOctokit({
log: consoleLogLevel({
auth: "secret123",
level: "info",
}),
});
Contributing
See CONTRIBUTING.md