Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

debug

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debug

small debugging utility

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
130M
decreased by-54.65%
Maintainers
1
Weekly downloads
 
Created

What is debug?

The debug npm package is a flexible debugging utility that allows developers to log messages in a structured and conditional way. It is designed to be simple to use and to support modular applications by allowing developers to enable or disable logging on a per-module or per-scope basis.

What are debug's main functionalities?

Conditional Logging

This feature allows developers to create conditional logging statements that can be enabled or disabled based on the namespace. The '%o' formatter can be used to pretty-print objects.

const debug = require('debug')('http');
debug('booting %o', 'My App');
if (error) debug('Error: %o', error);

Namespacing Logs

Namespacing allows developers to categorize logs into different sections, which can be individually toggled on or off. This is useful for separating logs from different parts of an application.

const debug = require('debug');
const log = debug('myapp:log');
const error = debug('myapp:error');
log('This will be logged under the myapp:log namespace');
error('This will be logged under the myapp:error namespace');

Environment Variable Control

The debug package can be controlled using the DEBUG environment variable, which allows developers to specify which namespaces should be logged. This can be set before running the application.

DEBUG=myapp:* node app.js

Browser Support

The debug package also works in the browser. Namespaces can be enabled by setting the debug key in localStorage to the desired namespace.

localStorage.debug = 'myapp:*';

Other packages similar to debug

Keywords

FAQs

Package last updated on 02 Feb 2012

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