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