Registry / devops / ts-log

ts-log

JSON →
library3.0.2jsnpmunverified

ts-log provides a minimal TypeScript Logger interface and a no-op dummyLogger that implements it, allowing libraries to accept a logger dependency without forcing one. Version 3.0.2 (latest stable) requires Node >=20 and ships both ESM and CJS modules. It has zero runtime dependencies and is designed to be compatible with console, pino, bunyan, winston, and any object matching the five-method shape (trace, debug, info, warn, error). Releases are infrequent but stable, focused on maintaining the minimal API. Key differentiator: lightweight, typed, and library-friendly with no overhead.

npm install ts-log
INSTALL
IMPORT
SIG · TS-LOG
T
ts-log
devopsjavascriptv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Logger
import { Logger } from 'ts-log'
import Logger from 'ts-log'
Logger is a named export, not a default export.
dummyLogger
import { dummyLogger } from 'ts-log'
const dummyLogger = require('ts-log').dummyLogger
CJS require is supported but TypeScript projects should use ESM import.
Logger type
import type { Logger } from 'ts-log'
import { Logger } from 'ts-log' // not wrong, but type import is cleaner for type-only usage
Use type import for type-only usage to avoid runtime overhead.

Shows how to accept a Logger dependency with a no-op default and use it in a class.

import { Logger, dummyLogger } from 'ts-log'; class MyService { private logger: Logger; constructor(logger?: Logger) { this.logger = logger ?? dummyLogger; } doSomething() { this.logger.info('hello'); } } const service = new MyService(); service.doSomething(); // no output const serviceWithConsole = new MyService(console); serviceWithConsole.doSomething(); // logs 'hello'
Debug
Known issues
breakingts-log v3 drops support for Node.js <20 and CommonJS default exports.
fix
Upgrade to Node.js >=20 and use named ESM imports.
affects: >=3.0.0
deprecatedPrevious builds (v2) output to build/src/, v3 outputs to dist/.
fix
Update import paths or migrate to v3 with new structure.
affects: <3.0.0
gotchaThe dummyLogger does nothing; it will not throw or log. Ensure your code handles silent failures correctly.
fix
Test with a real logger to verify log output is as expected.
affects: >=0.0.0
gotchaThe Logger interface is intentionally minimal; it does not include child() or other advanced methods.
fix
Use a full-featured logger like pino if you need child loggers or log levels beyond the five basic ones.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'ts-log' or its corresponding type declarations.
Package not installed or Node.js version incompatible with v3.
fix
Run `npm install ts-log` and ensure Node.js >=20 (or use ts-log v2 for older Node.js).
Module '"ts-log"' has no exported member 'dummyLogger'.
Using a version of ts-log that does not export dummyLogger (v1 had different export structure).
fix
Upgrade to ts-log >=2.0.0 which exports dummyLogger.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
packagets-log
ts-log — npm install ts-log · libregistry