npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mkusaka/debug

v0.0.6

Published

debug function

Readme

@mkusaka/js-debug

A simple yet powerful TypeScript logger that outputs structured JSON logs, including caller file location in the format filepath:line:col. It also supports context inheritance via a clone() method, allowing you to maintain common logging metadata across your application.

Features

  • Structured JSON logs: Outputs logs as JSON, including timestamp, level, message, context, and file location.
  • Caller file location: Includes the calling file path and position (filepath:line:col), making it easier to jump to code in many editors/terminals.
  • Context inheritance: Use clone() to create a new logger that merges parent context with additional context (e.g., request ID).
  • Log levels: Supports debug, info, warn, and error.
  • TypeScript: Fully written in TypeScript for type safety.

Installation

npm install --save @mkusaka/js-debug

Usage

// logger.ts
import { Logger } from "@mkusaka/js-debug";

// 1. Create a logger with optional context
const logger = new Logger({ service: "my-service" });

// 2. Log messages
logger.info("Hello from our service", { foo: "bar" });
logger.error("Something went wrong", { code: 500 });

// 3. Clone the logger to add more context
const childLogger = logger.clone({ requestId: "123abc" });
childLogger.debug("This is a child logger message");

Sample Output

When calling logger.info("Hello from our service", { foo: "bar" }), you might see something like:

{
  "level": "info",
  "timestamp": "2025-01-09T12:00:00.000Z",
  "message": "Hello from our service",
  "context": {
    "service": "my-service",
    "foo": "bar"
  },
  "fileLocation": "/path/to/your/project/example.ts:10:12"
}

Depending on your environment (e.g., VSCode integrated terminal), you can often click the fileLocation (/path/to/your/project/example.ts:10:12) to jump straight to the relevant line and column.

API

class Logger

constructor(context: LoggerContext = {})
  • Creates a new logger with the given context object.
  • LoggerContext is just a map: { [key: string]: any }.

logger.clone(additionalContext: LoggerContext = {}): Logger

  • Returns a new Logger instance that merges the parent context with additionalContext.

logger.debug(message: any, ...args: any[]): void

Logs a debug-level message with optional arguments.

logger.info(message: any, ...args: any[]): void

Logs an info-level message with optional arguments.

logger.warn(message: any, ...args: any[]): void

Logs a warn-level message with optional arguments.

logger.error(message: any, ...args: any[]): void

Logs an error-level message with optional arguments.

Configuration

  • Log output: The default sample logs to console.log. Adjust to your preferred output (e.g., files, log aggregation service) if needed.
  • Call stack depth: The library uses getCallSite(2) by default to obtain the file location from two levels above the call (i.e., user code -> logger method -> internal log function). If you wrap logger methods further, you may need to adjust the depth.

Contributing

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/my-new-feature).
  3. Commit your changes (git commit -m 'Add my new feature').
  4. Push to the branch (git push origin feature/my-new-feature).
  5. Open a pull request.

License

This project is licensed under the MIT License.

Feel free to modify and distribute it as per the license terms.