mrkeyoor.com_
Wed 23 Sept 02:54 UTC
npmWeb Frontendupdated 22 Sept 2026

loglevel-plugin-prefix review

loglevel-plugin-prefix 0.8.4 wraps loglevel's method factory so console messages can start with a timestamp, severity, or named-logger label. `reg(log)` installs the plugin once; `apply(logger, options)` selects a token template or a formatter. It changes presentation only. There are no JSON records, transports, redaction rules, files, or remote delivery. Our full browser build was 2.3 KB minified and 1.2 KB gzipped. The latest npm release is still the June 2018 build, and its README continues to label the API unstable despite years of practical immobility.

Verdict

loglevel-plugin-prefix 0.8.4 installed in 0.5 seconds and added a 1.2 KB gzipped browser bundle in our sandbox, but npm has not released it since 2018. Keep it as small browser glue for an existing loglevel stack; do not mistake it for a production logging backend.

We installed it

Lab card: what happened when we installed loglevel-plugin-prefixScreenshot of loglevel-plugin-prefix documentation
Install✓ · 0.5s1 package on disk · 1 MB
ImportESM import works · require() works · CommonJS package
Browser1.2 KBgzipped (2.3 KB minified), bundled with esbuild
TypesTypeScript types bundled
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does loglevel-plugin-prefix install cleanly?

Yes. In a fresh container with an empty cache, npm install loglevel-plugin-prefix finished in 0.5s, leaving 1 package and 1 MB on disk. npm audit reported no known vulnerabilities.

How much does loglevel-plugin-prefix add to a browser bundle?

1.2 KB gzipped (2.3 KB minified) when the whole package is bundled for the browser with esbuild. Importing only part of it is usually smaller.

Does loglevel-plugin-prefix work with both ESM and CommonJS?

Yes. Both import 'loglevel-plugin-prefix' and require('loglevel-plugin-prefix') worked in Node 22 in our run. The package is published as CommonJS.

Does loglevel-plugin-prefix include TypeScript types?

Yes, type declarations ship inside the package, so no @types install is needed.

loglevel-plugin-prefix or loglevel: which should you use?

loglevel: Use loglevel alone and own a short methodFactory wrapper when one prefix convention is enough. loglevel-plugin-prefix 0.8.4 installed in 0.5 seconds and added a 1.2 KB gzipped browser bundle in our sandbox, but npm has not released it since 2018.

When should you not use loglevel-plugin-prefix?

Production needs structured JSON, serializers, redaction, child bindings, or transports; this plugin only prepends text

API stability3/5The practical interface has stayed at 2 calls since 0.8.4: register the root loglevel object, then apply options to a logger. Repeated applications update stored configuration without nesting wrappers. The README still declares the API unstable, limits compatibility promises to patch releases, and predicts a future error for apply-before-reg. Long inactivity freezes behavior but does not amount to a written stability guarantee.
Docs3/5The README lists both calls, every default formatter, all 3 template tokens, option inheritance, named loggers, browser globals, and complete console examples. It omits the single-replacement token behavior and object-argument shape. More seriously, runtime sends a formatted string into the custom `format` callback while the bundled TypeScript declaration says Date, so the first-party sources disagree on an observable value.
Maintenance1/5npm published 0.8.4 on 2018-06-18. The unarchived GitHub repository was last pushed on 2022-02-11 and showed 12 open issues and pull requests when checked. The README still speaks about a next release that has not arrived. Small code can remain usable for years, yet stale declarations and reported inheritance behavior have no published correction.
Ecosystem3/5npm counted 3,667,184 downloads in the week ending 2026-08-24, and our install added only 1 package. It plugs directly into loglevel in Node and browsers, including named logger support and old script-tag use. The project has 64 GitHub stars, declares no peer relationship with loglevel, and owns no transport or formatter ecosystem; most reach is inherited from older dependency trees.

Use it if

  • A browser application already uses loglevel and needs readable prefixes with little added code
  • Named loglevel channels need distinct labels such as api, auth, or cache
  • You only need synchronous formatting of level, logger name, and time
  • A legacy script-tag page loads both packages as browser globals
Skip it if

Setup reality

We installed loglevel-plugin-prefix 0.8.4 in 0.5 seconds. The clean sandbox contained 1 package and used 1 MB on disk; the tarball was 128 KB unpacked with 0 dependencies and 0 peers. npm audit found 0 known vulnerabilities. CommonJS and ESM imports both worked even though there is no exports map. TypeScript declarations are bundled.

Install loglevel separately because this package does not declare it as a dependency or peer. Import both modules, call prefix.reg(log) with the root logger, then call prefix.apply() on the root or a named logger. Applying first currently warns. The README says a future release would throw, but no release after 0.8.4 has delivered that change.

Our namespace browser bundle measured 2.3 KB minified and 1.2 KB gzipped. Templates recognize %t, %l, and %n; version 0.8.4 replaces only the first instance of each token. When format and template are both present, template formatting wins. Reapplying options asks loglevel to rebuild its methods instead of stacking another wrapper.

A string message receives the prefix inside its first argument, preserving console substitutions. For an object, the prefix becomes a separate leading argument, which can change custom sink behavior. timestampFormatter receives a Date, then its return value reaches format; the included declaration incorrectly types that later value as Date. Test one string, one object, a named logger, and reconfiguration in the bundling arrangement you ship.

Patterns

Prefix the root logger register-prefix

const log = require('loglevel')
const prefix = require('loglevel-plugin-prefix')

prefix.reg(log)
prefix.apply(log)
log.setLevel('info')
log.info('connected')

Call `reg()` before `apply()`; the default uses local `HH:MM:SS` time and an uppercase level.

Print time, level, and logger name configure-template

prefix.apply(log, { template: '[%t] %l %n:' })
log.getLogger('api').warn('slow response')

Only `%t`, `%l`, and `%n` are recognized, and 0.8.4 replaces the first occurrence of each.

Emit an ISO timestamp format-iso-time

prefix.apply(log, {
  template: '[%t] %l:',
  timestampFormatter: (date) => date.toISOString(),
})

`timestampFormatter` receives a Date; its returned string is what the template and custom formatter see.

Build the prefix in one function customize-format

prefix.apply(log, {
  format(level, name, timestamp) {
    return `${timestamp} ${level} [${name}]`
  },
})

Runtime passes a string for `timestamp`; version 0.8.4's declaration says Date and is inaccurate here.

Give auth logs a separate label prefix-named-logger

const authLog = log.getLogger('auth')
prefix.apply(authLog, { template: '%l (%n):' })
authLog.error('token expired')

Register the root object once, then apply named options to loggers returned by `getLogger()`.

Change the active template reconfigure-prefix

prefix.apply(log, { template: '%l:' })
log.info('plain')
prefix.apply(log, { template: '[%t] %l:' })
log.info('timed')

The second application replaces configuration and rebuilds loglevel methods; it does not add a second prefix.

Keep console placeholders aligned preserve-substitutions

prefix.apply(log, { template: '%l:' })
log.info('processed %d records in %d ms', count, elapsedMs)

For a string first argument, the prefix joins that same string, leaving `%d` arguments in their original positions.

Register from pinned script tags load-browser-globals

<script src="https://unpkg.com/loglevel/dist/loglevel.min.js"></script>
<script src="https://unpkg.com/loglevel-plugin-prefix@0.8.4/dist/loglevel-plugin-prefix.min.js"></script>
<script>
  prefix.reg(log)
  prefix.apply(log, { template: '[%t] %l:' })
</script>

Pin 0.8.4 in production. The global names are `log` and `prefix`, and both libraries offer `noConflict()`.

Alternatives

PackageRegistryPick it when
loglevelnpmUse loglevel alone and own a short methodFactory wrapper when one prefix convention is enough.
pinonpmUse it for structured Node logs, child bindings, serializers, and redaction.
winstonnpmUse it when a Node process needs multiple transports and a configurable formatting pipeline.
debugnpmUse it for namespaced diagnostics that operators enable through the DEBUG setting.

More web frontend guides

postcss · react · react-dom · tailwindcss · htmlparser2 · tailwind-merge · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.