Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@octokit/plugin-request-log
Advanced tools
@octokit/plugin-request-log is a plugin for Octokit that logs all requests made to the GitHub API. It is useful for debugging and monitoring the requests your application makes to GitHub.
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();
axios-debug-log is a middleware for Axios that logs request and response details. It is similar to @octokit/plugin-request-log in that it provides logging capabilities for HTTP requests, but it is designed specifically for Axios rather than Octokit.
winston is a versatile logging library for Node.js. While it is not specifically designed for logging HTTP requests, it can be used in conjunction with request libraries to log request and response details. It offers more advanced logging features compared to @octokit/plugin-request-log.
morgan is an HTTP request logger middleware for Node.js. It is commonly used with Express.js to log incoming HTTP requests. Unlike @octokit/plugin-request-log, which is specific to Octokit and GitHub API requests, morgan is a general-purpose HTTP request logger.
Log all requests and request errors
Browsers |
Load
|
---|---|
Node |
Install with
|
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
const octokit = new MyOctokit({
log: require("console-log-level")({
auth: "secret123",
level: "info",
}),
});
See CONTRIBUTING.md
FAQs
Log all requests and request errors
The npm package @octokit/plugin-request-log receives a total of 4,691,883 weekly downloads. As such, @octokit/plugin-request-log popularity was classified as popular.
We found that @octokit/plugin-request-log demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.