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

@matumo/ts-simple-logger

v1.1.0

Published

Simple console logger for browsers and Node.

Readme

ts-simple-logger

Simple console logger for browsers and Node.

  • Zero dependencies
  • Log levels: trace, debug, info, warn, error, silent
  • Multiple named loggers
  • Default config and per-logger overrides
  • Configurable prefix with placeholders
  • Uses native console.*, keeping the browser devtools source location where possible

Published

https://www.npmjs.com/package/@matumo/ts-simple-logger

Installation

npm install @matumo/ts-simple-logger

Loading

Choose the loading style for your environment. After loading, the API usage is the same.

ESM:

import { getLogger, setDefaultConfig, setLoggerConfig } from "@matumo/ts-simple-logger";

CommonJS / CJS:

const { getLogger, setDefaultConfig, setLoggerConfig } = require("@matumo/ts-simple-logger");

Web (ESM):

<script type="module">
  import { getLogger, setDefaultConfig, setLoggerConfig } from "./dist/index.js";
</script>

Web (IIFE):

<script src="./dist/index.iife.js"></script>
<script>
  const { getLogger, setDefaultConfig, setLoggerConfig } = globalThis.TsSimpleLogger;
</script>

For browser usage, you can also serve dist/index.js or dist/index.iife.js from a CDN such as jsDelivr.

Usage

import { getLogger, setDefaultConfig, setLoggerConfig } from "@matumo/ts-simple-logger";

setDefaultConfig({
  level: "info",
  placeholders: {
    "%appName": "myapp",
    "%time": () => new Date().toISOString(),
  },
  prefixFormat: "[%appName] %time (%loggerName) %logLevel:",
  // Built-in placeholders: `%loggerName`, `%logLevel`.
  // Use `%%` in prefixFormat for a literal `%`.
  // Placeholder functions run at log time and must return strings.
});

const app = getLogger("app");
const db = getLogger("db");

setLoggerConfig("db", {
  level: "debug",
  placeholders: { "%appName": "myapp-db" },
});

app.info("started");
// [myapp] 2000-01-01T00:00:00.000Z (app) INFO: started
db.debug("connected", { host: "127.0.0.1" });
// [myapp-db] 2000-01-01T00:00:00.000Z (db) DEBUG: connected { host: "127.0.0.1" }

Configuration

Options for setDefaultConfig and setLoggerConfig:

  • level: minimum log level
  • prefixEnabled: enable/disable prefix
  • prefixFormat: prefix template with placeholders
  • placeholders: custom placeholder map

Log levels: trace, debug, info, warn, error, silent

Placeholders:

  • Built-in: %loggerName, %logLevel
  • Custom keys must start with %
    • After %, you can use:
      • ASCII letters: A-Z, a-z
      • Digits: 0-9
      • Underscore: _
      • Hyphen: - between segments
    • Examples: %appName, %app-name, %APP_2
  • Reserved placeholders %loggerName and %logLevel cannot be overridden, and the escape token %% is also reserved
  • Unknown placeholders remain as-is; use %% for a literal %
  • Placeholder functions are evaluated at log time
  • Default and per-logger placeholder updates are merged by key
  • Effective per-logger placeholders merge defaults and overrides, with per-logger values taking precedence on key conflicts

Prefix behavior:

  • If prefixEnabled is false, only the original arguments are logged
  • If prefixEnabled is true, the logger always uses the configured prefix path
    • This also applies when prefixFormat is an empty string or placeholder expansion resolves the prefix to an empty string
    • If you want to avoid whitespace in that case, set prefixEnabled to false

Config resolution:

  • Unspecified per-logger fields always fall back to defaults
  • Changing defaults after a logger is retrieved updates its unspecified fields
  • Changing per-logger config re-applies immediately to that logger
  • Default changes never override fields set in per-logger config

Defaults at startup:

  • level: info
  • prefixEnabled: true
  • prefixFormat: (%loggerName) %logLevel:
  • placeholders: {}

API

Argument types:

// Log level order used for filtering.
type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
// Placeholder value can be static or computed at log time.
type PlaceholderValue = string | (() => string);
// Placeholder map like { "%appName": "myapp" }.
type Placeholders = Record<string, PlaceholderValue>;
// Full config with required fields.
type LoggerConfig = {
  level: LogLevel;
  prefixEnabled: boolean;
  prefixFormat: string;
  placeholders: Placeholders;
};
// Partial update for defaults or per-logger overrides.
type LoggerConfigPatch = Partial<LoggerConfig>;

API signatures:

// Get a named logger (see "Logger usage" below).
getLogger(name: string): Logger;

// Update global defaults.
setDefaultConfig(patch: LoggerConfigPatch): void;
// Update per-logger overrides.
setLoggerConfig(name: string, patch: LoggerConfigPatch): void;

// Set global log level shortcut.
setLogLevel(level: LogLevel): void;
// Set per-logger log level shortcut.
setLoggerLevel(name: string, level: LogLevel): void;

// Get current defaults.
getDefaultConfig(): Readonly<LoggerConfig>;
// Get per-logger overrides for a logger.
getLoggerOverrides(name: string): Readonly<LoggerConfigPatch>;
// Get resolved config (defaults + overrides) for a logger.
getEffectiveLoggerConfig(name: string): Readonly<LoggerConfig>;
// Get library defaults (initial baseline).
getLibraryDefaults(): Readonly<LoggerConfig>;

Logger usage:

const log: Logger = getLogger("app");
log.info("started");
log.error("details", { code: "E_CONN" });

Console Notes

  • This library logs via console.*.
  • If a specific console method is missing, it falls back to console.log
  • If console is not defined, logging is a no-op