forked from athombv/node-zigbee-clusters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (53 loc) · 1.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
const _debug = require('debug');
const ZCLNode = require('./lib/Node');
const Cluster = require('./lib/Cluster');
const Clusters = require('./lib/clusters');
const BoundCluster = require('./lib/BoundCluster');
const zclTypes = require('./lib/zclTypes');
const zclFrames = require('./lib/zclFrames');
/**
* Enables or disables debug logging.
* @param {boolean} flag - Set to true to enable logging
* @param {string} namespaces - As specified by [`debug`](https://www.npmjs.com/package/debug)
* npm module (e.g.
* `zigbee-clusters:bound-cluster:*`).
*
* @example
*
* const { debug } = require('zigbee-clusters');
*
* // Enables debug logging in zigbee-clusters
* debug(true);
*/
function debug(flag = true, namespaces = '*') {
// If arg is boolean and true, or string with length consider logging to be enabled
if (flag) {
// TODO: currently `debug.enable()` overrides all enabled namespaces, this is likely to be
// fixed in [email protected] (see: https://github.com/visionmedia/debug/issues/425). Until then
// enable all ('*') to prevent disabling others.
_debug.enable(namespaces);
return;
}
// Disable all, only thing we can do here
// TODO: maybe from [email protected] we can disable specific namespaces, in that case only disable
// the `zigbee-clusters` namespace.
_debug.disable();
}
const {
ZCLDataTypes,
ZCLDataType,
ZCLStruct,
} = zclTypes;
module.exports = {
Cluster,
BoundCluster,
ZCLNode,
zclTypes,
zclFrames,
ZCLDataTypes,
ZCLDataType,
ZCLStruct,
...Clusters,
debug,
};