debug

Create namespaced loggers with DEBUG, localStorage, or environment variable controls.

81.4k|15.8k|Updated May 21, 2023
One-click install
npx skills add https://github.com/lobehub/lobehub --skill debug-lobehub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: debug
Source: https://github.com/lobehub/lobehub/tree/main/.agents/skills/debug
Command: npx skills add https://github.com/lobehub/lobehub --skill debug-lobehub

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Debugging across large codebases can be noisy and hard to trace. The debug library provides a lightweight, namespaced logger to standardize log output and help you quickly identify where messages originate.

Core Features & Use Cases

  • Namespaced loggers: create loggers with patterns like lobe-server:market
  • Enable/disable output easily: use DEBUG or browser localStorage to toggle logs without code changes
  • Format support: supports %O, %o, %s, %d for structured output
  • Cross-environment use: applicable to server, client, and desktop apps
  • Quick diagnostics: quickly surface issues during development and in production troubleshooting

Quick Start

Use the debug library to create a logger for a module, e.g.: const log = debug('lobe-server:market'); log('message goes here')

Frequently Asked Questions about debug

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement namespaced logging in Node.js to trace issues across modules?

Namespaced logging in Node.js uses the debug library to create per-module loggers, such as const log = debug('lobe-server:market'), allowing you to trace exactly where messages originate without code changes.

How can I enable or disable debug output in browser applications?

You can enable or disable debug output in browser applications by setting the debug value in the localStorage, toggling per-module log visibility directly without modifying your application code.

Does the debug library support structured logging with format placeholders?

Yes, the debug library supports structured logging with standard format placeholders including %O, %o, %s, and %d, allowing you to format complex objects and variables directly in your diagnostic messages.

What is the best way to control diagnostic logging across server and client environments?

The best way to control diagnostic logging across server and client environments is using environment variables like DEBUG on the server and localStorage in the browser, standardizing output across contexts.

Why should I use namespaced debug loggers instead of standard console.log for diagnostics?

Namespaced debug loggers prevent noisy codebases by allowing you to filter output by namespace patterns, unlike standard console.log which outputs indiscriminately and makes production troubleshooting difficult.

Can I use this namespaced debugging approach for desktop applications?

Yes, this namespaced debugging approach is explicitly applicable across server, client, and desktop app contexts, providing a consistent per-module log output management system throughout your environments.