TypeScript Abstract Logger
Abstract logger TypeScript interface along with a dummy logger that does nothing.
Useful for libraries wanting to provide a pluggable logger that does nothing by default (or provide your own default such as bunyan).
- Matches the built-in console that can be used directly.
- Also matches bunyan.
- Provides usage and custom logger example.
- Written in TypeScript, no need for extra typings.
- No dependencies, 24 LOC with comments, 100% test coverage.
This package is distributed via npm
npm install ts-log
yarn add ts-log
;;// example class that uses the logger// example custom logger that logs to a file// don't define a logger, defaults to dummy logger that does nothing;// use the built-in console as the logger;// use the custom file logger;// run the calculatorcalculator1.sum2, 3;calculator2.sum-4, 1;calculator3.sum6, 3;
npm startto start the example application.
npm run buildto build the production version.
npm run testto run tests.
npm run coverageto gather code coverage.
npm run lintto lint the codebase.
npm run prettierto run prettier.
npm run validateto run all pre-commit checks (prettier, build, lint, test)