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

log-shape

v0.3.0

Published

[![npm](https://img.shields.io/npm/v/log-shape)](https://www.npmjs.com/package/log-shape) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Readme

npm License: MIT

log-shape

log-shape is a TypeScript CLI that scans JS/TS source files and highlights inconsistent logging patterns. It uses static regex analysis to classify console.*, logger.*, pino.*, and winston.* calls, then reports mixed styles and distribution across the codebase.

Install

pnpm add -D log-shape

Or run locally from this repo:

pnpm install
pnpm build
node dist/index.js src/

Usage

log-shape <path> [options]

Options:

  • --json JSON output
  • --no-fail Don't exit with status code 1 on inconsistent files
  • --ext <exts> Comma-separated extensions to scan, default: .ts,.js,.tsx,.jsx
  • --ignore <pat> Comma-separated glob patterns to ignore, default: node_modules,dist,test
  • --config <path> Load .logshaperc JSON config from the current working directory or a custom path
  • --fix Rewrite supported console.* calls to a consistent target style
  • --target <style> Rewrite target: structured or template, default: structured
  • --migrate <style> Rewrite supported log calls to pino, winston, bunyan, or console style
  • --report <mode> Report output mode: text, json, or html
  • --dry-run Preview rewrites without modifying files
  • --suggest Show pino/winston migration snippets

Example:

log-shape src/ --suggest

Fix mode example:

log-shape src/ --fix --target structured --dry-run

Migration mode example:

log-shape src/ --migrate pino

Report mode examples:

log-shape src/ --report json
log-shape src/ --report html > log-report.html

What It Detects

Each supported log call is classified into one of these styles:

  • structured logger.info({ msg: "ok" })
  • string-concat console.log("user:", user)
  • template-literal console.log(`token=${token}`)
  • raw-dump console.log(obj)
  • plain-string console.log("simple message")

Files with more than two distinct styles are flagged as inconsistent.

You can tighten that rule with config by setting maxMixedStyles, or explicitly allow only certain styles with allowStyles.

Config

log-shape automatically loads .logshaperc from the current working directory when present. You can also point at a specific file with --config.

Example:

{
  "logger": "pino",
  "allowStyles": ["structured"],
  "ignoreFiles": ["src/legacy/**"],
  "maxMixedStyles": 1
}

Fields:

  • logger: logger family to emit during --fix rewrites. pino and winston emit logger.info(...) / logger.error(...); console keeps console.*(...)
  • allowStyles: styles considered acceptable during reporting
  • ignoreFiles: additional glob patterns to skip during scan/fix
  • maxMixedStyles: maximum distinct styles allowed per file before it is flagged

How It Works

log-shape uses line-based static regex analysis. It does not execute code or build a full AST. This keeps the CLI fast and simple, but means it is intentionally best-effort for common single-line logging patterns.

Round 3

  • --migrate <style> rewrites recognized single-line logging calls and adds or removes import logger from "..."; when needed
  • --report json exposes a summary block with total calls, style counts, inconsistent files, and a heuristic score
  • --report html emits a standalone HTML report suitable for CI artifacts

Migration Guide

If mixed styles are detected, move toward structured logging:

Pino

import pino from "pino";

const logger = pino();
logger.info({ msg: "starting", port });
logger.error({ msg: "db failed", err });

Winston

import winston from "winston";

const logger = winston.createLogger({
  transports: [new winston.transports.Console()]
});

logger.info({ msg: "starting", port });
logger.error({ msg: "db failed", err });

Development

pnpm install
pnpm build
pnpm test