Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielkucal/ts-debug
Console that logs where you want. Written in TypeScript ♥
https://github.com/danielkucal/ts-debug
angular console debugger debugging-tool javascript typescript
Last synced: 3 months ago
JSON representation
Console that logs where you want. Written in TypeScript ♥
- Host: GitHub
- URL: https://github.com/danielkucal/ts-debug
- Owner: DanielKucal
- License: mit
- Created: 2017-06-06T00:05:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-01T11:22:15.000Z (almost 3 years ago)
- Last Synced: 2024-10-13T01:05:49.100Z (4 months ago)
- Topics: angular, console, debugger, debugging-tool, javascript, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/ts-debug
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Typescript Debugger
## Console Wrappper
This tiny lib written in Typescript allows you to leave your debugging logs inside your project without worries of removing them for production environment.### Installation
```
npm install --save ts-debug
```### Usage
`Debugger`'s instance has the exactly same methods as standard `console`. Its constructor takes 3 parameters:
+ `console: Console` - object implementing Console interface, e.g. `console` or its wrapper
+ `isEnabled: boolean = true` - determines if Debugger should be enabled (you shoud pass here `false` to prevent displaying console output in production environment)
+ `prefix: string = ''` - specifies prefix for console outputs, e.g. `"[DEBUG] "`#### Example:
```
import { Debugger } from 'ts-debug';
const Config = { isProd: false }; // example config in your applicationconst debug = new Debugger(console, !Config.isProd, '[DEBUG] ');
debug.log('Debugger is enabled!');
debug.warn('An error occured while processing: ', { example: 'object' });
```You can see real-life usage of this lib in [ngx-store](https://github.com/zoomsphere/ngx-store).
### Additional methods
- `throw(error: Error)` - throws usual (sync) error in debug mode and non-blocking (async) otherwise### Compatibility
For TypeScript 3+ use v1.3+
For older versions use v1.2