Socket
Socket
Sign inDemoInstall

callsite-record

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callsite-record

Create fancy log entries for errors and function call sites.


Version published
Maintainers
1
Created

What is callsite-record?

The callsite-record npm package is used to capture and format call site information in Node.js. It is particularly useful for debugging and logging purposes, as it allows developers to obtain detailed information about the call stack, including file names, line numbers, and function names.

What are callsite-record's main functionalities?

Capture Call Site Information

This feature allows you to capture call site information by creating a new Error object and passing it to callsite-record. The renderSync method is then used to format and display the call site information.

const callsiteRecord = require('callsite-record');

function getCallSite() {
  const record = callsiteRecord({ forError: new Error() });
  console.log(record.renderSync());
}

getCallSite();

Asynchronous Call Site Information

This feature allows you to capture call site information asynchronously. The render method returns a promise that resolves to the formatted call site information.

const callsiteRecord = require('callsite-record');

async function getAsyncCallSite() {
  const record = await callsiteRecord({ forError: new Error() }).render();
  console.log(record);
}

getAsyncCallSite();

Custom Error Handling

This feature demonstrates how to use callsite-record for custom error handling. When an error is caught, the customErrorHandler function captures and logs the call site information.

const callsiteRecord = require('callsite-record');

function customErrorHandler(err) {
  const record = callsiteRecord({ forError: err });
  console.log(record.renderSync());
}

try {
  throw new Error('Something went wrong');
} catch (err) {
  customErrorHandler(err);
}

Other packages similar to callsite-record

Keywords

FAQs

Package last updated on 20 Jun 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc