add topic oriented debugging selection
This commit is contained in:
parent
4cb7b82e0b
commit
9c01368fe9
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1,5 +1,6 @@
|
||||
export declare class SmartDebug {
|
||||
private _debugEnabled;
|
||||
constructor(debugTopic?: string);
|
||||
readonly debugEnabled: boolean;
|
||||
/**
|
||||
* enables debugging output
|
||||
|
9
dist/index.js
vendored
9
dist/index.js
vendored
@ -1,8 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class SmartDebug {
|
||||
constructor() {
|
||||
constructor(debugTopic) {
|
||||
this._debugEnabled = false;
|
||||
if (process.env.SMARTDEBUG === 'true' ||
|
||||
(debugTopic && process.env.SMARTDEBUG_TOPIC === debugTopic)) {
|
||||
this.enableDebugging();
|
||||
}
|
||||
}
|
||||
get debugEnabled() {
|
||||
return this._debugEnabled;
|
||||
@ -11,6 +15,7 @@ class SmartDebug {
|
||||
* enables debugging output
|
||||
*/
|
||||
enableDebugging() {
|
||||
console.log('Enabled Debugging!');
|
||||
this._debugEnabled = true;
|
||||
}
|
||||
/**
|
||||
@ -36,4 +41,4 @@ class SmartDebug {
|
||||
}
|
||||
}
|
||||
exports.SmartDebug = SmartDebug;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBO0lBQUE7UUFDVSxrQkFBYSxHQUFZLEtBQUssQ0FBQztJQW1DekMsQ0FBQztJQWxDQyxJQUFJLFlBQVk7UUFDZCxPQUFPLElBQUksQ0FBQyxhQUFhLENBQUM7SUFDNUIsQ0FBQztJQUVEOztPQUVHO0lBQ0ksZUFBZTtRQUNwQixJQUFJLENBQUMsYUFBYSxHQUFHLElBQUksQ0FBQztJQUM1QixDQUFDO0lBRUQ7O09BR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UNJLGdCQUFnQjtRQUNyQixJQUFJLENBQUMsYUFBYSxHQUFHLEtBQUssQ0FBQztJQUM3QixDQUFDO0lBRUQ7O09BRUc7SUFDSSxHQUFHLENBQUMsU0FBYztRQUN2QixJQUFJLElBQUksQ0FBQyxhQUFhLEVBQUU7WUFDdEIsc0NBQXNDO1lBQ3RDLE9BQU8sQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUM7U0FDeEI7SUFDSCxDQUFDO0lBRUQ7O09BRUc7SUFDSSxXQUFXO1FBQ2hCLE9BQU8sSUFBSSxDQUFDLGFBQWEsQ0FBQztJQUM1QixDQUFDO0NBQ0Y7QUEvQ0QsZ0NBK0NDIn0=
|
16
readme.md
16
readme.md
@ -1,13 +1,16 @@
|
||||
# smartdebug
|
||||
|
||||
debug the smart way
|
||||
|
||||
## Availabililty
|
||||
|
||||
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/@pushrocks/smartdebug)
|
||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartdebug)
|
||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartdebug)
|
||||
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartdebug/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[![build status](https://GitLab.com/pushrocks/smartdebug/badges/master/build.svg)](https://GitLab.com/pushrocks/smartdebug/commits/master)
|
||||
[![coverage report](https://GitLab.com/pushrocks/smartdebug/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartdebug/commits/master)
|
||||
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartdebug.svg)](https://www.npmjs.com/package/@pushrocks/smartdebug)
|
||||
@ -19,23 +22,24 @@ debug the smart way
|
||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
```typescript
|
||||
import * as smartdebug from '@pushrocks/smartdebug';
|
||||
|
||||
smartdebug.log('a cool message') // won't log
|
||||
smartdebug.log('a cool message'); // won't log
|
||||
smartdebug.enableDebugging();
|
||||
smartdebug.log('another cool message') // this message will log
|
||||
smartdebug.log('another cool message'); // this message will log
|
||||
|
||||
if(smartdebug.debugEnabled) {
|
||||
console.log('Hi there!') // will also log since debugging is enabled
|
||||
if (smartdebug.debugEnabled) {
|
||||
console.log('Hi there!'); // will also log since debugging is enabled
|
||||
}
|
||||
```
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
> licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
|
||||
|
@ -1,3 +1,4 @@
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import { expect, tap } from 'tapbundle';
|
||||
import * as smartdebug from '../ts/index';
|
||||
|
||||
|
15
ts/index.ts
15
ts/index.ts
@ -2,7 +2,17 @@ import * as plugins from './smartdebug.plugins';
|
||||
|
||||
export class SmartDebug {
|
||||
private _debugEnabled: boolean = false;
|
||||
get debugEnabled () {
|
||||
|
||||
constructor(debugTopic?: string) {
|
||||
if (
|
||||
process.env.SMARTDEBUG === 'true' ||
|
||||
(debugTopic && process.env.SMARTDEBUG_TOPIC === debugTopic)
|
||||
) {
|
||||
this.enableDebugging();
|
||||
}
|
||||
}
|
||||
|
||||
get debugEnabled() {
|
||||
return this._debugEnabled;
|
||||
}
|
||||
|
||||
@ -10,6 +20,7 @@ export class SmartDebug {
|
||||
* enables debugging output
|
||||
*/
|
||||
public enableDebugging() {
|
||||
console.log('Enabled Debugging!');
|
||||
this._debugEnabled = true;
|
||||
}
|
||||
|
||||
@ -31,7 +42,7 @@ export class SmartDebug {
|
||||
}
|
||||
|
||||
/**
|
||||
* a function returning
|
||||
* a function returning
|
||||
*/
|
||||
public isDebugMode() {
|
||||
return this._debugEnabled;
|
||||
|
@ -1 +1 @@
|
||||
export {};
|
||||
export {};
|
||||
|
Loading…
Reference in New Issue
Block a user