Logging Requests
This feature allows you to log all requests made to the GitHub API. The code sample demonstrates how to create an Octokit instance with the requestLog plugin and make a request to the GitHub API, which will be logged.
const { Octokit } = require('@octokit/core');
const { requestLog } = require('@octokit/plugin-request-log');
const MyOctokit = Octokit.plugin(requestLog);
const octokit = new MyOctokit();
async function logRequests() {
await octokit.request('GET /repos/{owner}/{repo}', {
owner: 'octocat',
repo: 'hello-world'
});
}
logRequests();
Custom Log Output
This feature allows you to customize the log output by providing your own logging functions. The code sample demonstrates how to create an Octokit instance with custom log functions and make a request to the GitHub API, which will be logged using the custom functions.
const { Octokit } = require('@octokit/core');
const { requestLog } = require('@octokit/plugin-request-log');
const MyOctokit = Octokit.plugin(requestLog);
const octokit = new MyOctokit({
log: {
debug: console.debug,
info: console.info,
warn: console.warn,
error: console.error
}
});
async function logRequests() {
await octokit.request('GET /repos/{owner}/{repo}', {
owner: 'octocat',
repo: 'hello-world'
});
}
logRequests();