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;
yarn startto start the example application.
yarn buildto build the production version.
yarn testto run tests.
yarn coverageto gather code coverage.
yarn lintto lint the codebase.
yarn prettierto run prettier.
yarn validateto run all pre-commit checks (prettier, build, lint, test)