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

where-log

v0.2.1

Published

Log values with caller file and line number.

Readme

where-log

Log a value with the caller file and line number.

Install

npm install where-log

Usage

import { log } from "where-log";

const user = { id: 1, name: "Shovon" };
log(user);

Output style:

user.tsx:44
{ id: 1, name: "Shovon" }

Label overload:

log("user", { id: 1, name: "Shovon" });

Options:

log(user, { colors: false });

log("user", user, {
  formatter: ({ location, label, value }) => ({
    locationLine: `[${location}]`,
    valueLine: `${label}: ${JSON.stringify(value)}`,
  }),
});

log(user, { mode: "fast", includeLocation: false });

Preset APIs:

import { createLogger, logDev, logProd } from "where-log";

logDev("user", user); // pretty + location
logProd("user", user); // fast + no location

const appLog = createLogger({ redact: ["user.token"], includeLocation: false });
appLog("request", { user: { token: "secret" } });
appLog.info("ready", { status: "ok" });

Level APIs:

import { debug, error, info, success, warn } from "where-log";

info("user", user);
success("saved", { id: 1 });
warn("quota", { remaining: 2 });
error("request", { status: 500 });
debug("trace", { step: "auth" });

Once / Timer / Context APIs:

import { once, time, timeEnd, withContext } from "where-log";

once("boot:db", "db connected");
once("boot:db", "db connected again"); // ignored

time("fetch-users");
// ... work
timeEnd("fetch-users", { total: 42 }, { warnThresholdMs: 200, errorThresholdMs: 800 });

const reqLog = withContext({ requestId: "req_123", userId: 7 }, { includeLocation: false });
reqLog.info("request", { path: "/api/users" });

Notes

  • Node.js: call-site detection is reliable with V8 stack traces.
  • Browser/Next.js: call-site depends on source maps and bundler/devtools behavior.
  • If stack parsing fails, the package prints unknown:0 on line 1.

Performance Tuning

  • mode: "pretty" (default): rich formatting via Node inspect.
  • mode: "fast": lower overhead formatting for hot paths.
  • includeLocation: false: skips stack capture/parsing.
  • inspectDepth: limit inspect depth in pretty mode.
  • enabled: false: disables log output quickly.

Safety / Readability

  • redact: mask sensitive values by path, e.g. ["password", "user.token"].
  • maxArrayLength: trim large arrays and append a summary item.
  • level helpers prepend compact tags by default ([INFO], [ERROR], etc.).

Session Helpers

  • once(key, ...): log only first occurrence per runtime session.
  • time(key) + timeEnd(key, ...): duration logging with optional thresholds.
  • resetOnce(keys?) and resetTimers(keys?): clear in-memory runtime state.
  • withContext(context): create logger with injected structured context.

API

  • log(value: unknown): void
  • log(value: unknown, options?: LogOptions): void
  • log(label: string, value: unknown, options?: LogOptions): void
  • info(...), success(...), warn(...), error(...), debug(...)
  • once(...), time(...), timeEnd(...)
  • logDev(...): dev preset (pretty, includeLocation: true, colors: true)
  • logProd(...): prod preset (fast, includeLocation: false, colors: false)
  • createLogger(presetOptions?: LogOptions): LoggerFn
  • withContext(context, presetOptions?): LoggerFn
  • resetOnce(keys?), resetTimers(keys?)
  • LogMode = "pretty" | "fast"
  • LogLevel = "info" | "success" | "warn" | "error" | "debug"
  • LogOptions
    • enabled?: boolean
    • mode?: LogMode (default "pretty")
    • includeLocation?: boolean (default true)
    • inspectDepth?: number (pretty mode only)
    • maxArrayLength?: number
    • redact?: string[]
    • level?: LogLevel
    • showLevelTag?: boolean
    • consoleMethod?: "log" | "info" | "warn" | "error" | "debug"
    • context?: Record<string, unknown>
    • clockNow?: () => number
    • warnThresholdMs?: number
    • errorThresholdMs?: number
    • includeDurationOnly?: boolean
    • colors?: boolean (Node only, default true)
    • formatter?: (input) => { locationLine: unknown; valueLine: unknown }