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

@maxjan/logger

v0.1.5

Published

Development logger that sends console output to Loki

Readme

@maxjan/logger

Development logger that wraps console and sends all logs to Loki/Grafana. Works with any JavaScript/TypeScript project.

In production, console works as normal - no logs are sent anywhere.

Installation

npm install @maxjan/logger

Quick Start

// lib/logger.ts
import { initLogger } from "@maxjan/logger";

initLogger({
  appName: "my-app",
});
// app/layout.tsx or index.ts - import once at app startup
import "./lib/logger";

// Now all console calls are sent to Loki
console.log("Hello");
console.warn("Warning!");
console.error("Something failed", { userId: 123 });

Configuration

initLogger({
  // Required
  appName: "my-app",

  // Optional
  lokiUrl: "http://127.0.0.1:3100/loki/api/v1/push", // default
  enabled: true, // default, set false to disable
  locale: "sv-SE", // default, for timestamp formatting
  labels: {
    env: "development",
    version: "1.0.0",
  },
});

API

initLogger(config)

Initialize the logger. Call once at app startup.

import { initLogger } from "@maxjan/logger";

initLogger({
  appName: "my-app",
  labels: { service: "api" },
});

setLabels(labels)

Add or update labels at runtime. Useful for adding request-specific context.

import { setLabels } from "@maxjan/logger";

setLabels({ userId: "123", requestId: "abc" });

disableLogger()

Disable the logger and restore original console behavior.

import { disableLogger } from "@maxjan/logger";

disableLogger();

Supported Console Methods

| Method | Loki Level | | ---------------- | ---------- | | console.log() | info | | console.info() | info | | console.warn() | warn | | console.error() | error | | console.debug() | debug | | console.trace() | debug |

Example: Next.js

// lib/logger.ts
import { initLogger } from "@maxjan/logger";

initLogger({
  appName: "my-nextjs-app",
  labels: {
    framework: "nextjs",
  },
});
// app/layout.tsx
import "@/lib/logger";

export default function RootLayout({ children }) {
  return <html>{children}</html>;
}

Example: Express

// index.ts
import { initLogger, setLabels } from "@maxjan/logger";
import express from "express";

initLogger({ appName: "my-api" });

const app = express();

app.use((req, res, next) => {
  setLabels({
    path: req.path,
    method: req.method,
  });
  next();
});

app.get("/", (req, res) => {
  console.log("Request received");
  res.send("Hello");
});

Querying in Grafana

# All logs from app
{app="my-app"}

# Only errors
{app="my-app", level="error"}

# Parse JSON and filter
{app="my-app"} | json | message =~ "user.*"

Requirements

  • Loki running locally (default: http://127.0.0.1:3100)
  • Node.js 18+

Development

npm install
npm run build
npm run dev     # watch mode
npm run test    # run tests
npm run lint    # check linting
npm run format  # format with prettier

Commit Format

This project uses Conventional Commits:

feat: add new feature      # minor version bump
fix: bug fix               # patch version bump
feat!: breaking change     # major version bump
docs: update documentation
chore: maintenance
refactor: code refactoring
perf: performance improvement

Release

npm run release           # auto-bump based on commits
npm run release:minor     # force minor bump
npm run release:major     # force major bump

This will:

  • Bump version in package.json
  • Generate/update CHANGELOG.md
  • Create git tag

License

MIT