typescript-log
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

TypeScript abstract logger

Useful for libraries which want to enable the consuming application to provide a logger. Our projects ended up duplicating the same logging interface and consoleLogger and noopLogger's.

Compatible with universal applications (works in browser and node)

Usage

import pino from 'pino'
import { consoleLogger, noopLogger, Logger } from 'typescript-log'
 
const pinoLogger: Logger = pino({})
 
const logsNothingLogger: Logger = noopLogger()
const logsToConsoleLogger: Logger = consoleLogger(
    /* optional, warn default */ 'error',
)

References

Similar to https://github.com/kallaspriit/ts-log but uses log(obj, msg) format for the interface

Package Sidebar

Install

npm i typescript-log

Weekly Downloads

2,971

Version

2.0.0

License

MIT

Unpacked Size

24.1 kB

Total Files

24

Last publish

Collaborators

  • jakeginnivan