@octokit/plugin-request-log
TypeScript icon, indicating that this package has built-in type declarations

5.1.1 • Public • Published

plugin-request-log.js

Log all requests and request errors

@latest Build Status

Usage

Browsers

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>
Node

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

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @octokit/plugin-request-log

Weekly Downloads

5,036,772

Version

5.1.1

License

MIT

Unpacked Size

5.81 kB

Total Files

7

Last publish

Collaborators

  • kfcampbell
  • nickfloyd
  • gr2m
  • octokitbot