@agoric/internal 0.2.2-dev-afff7db.0 → 0.2.2-dev-67ab902.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/debug.d.ts +2 -0
- package/src/debug.d.ts.map +1 -0
- package/src/debug.js +40 -0
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.2.2-dev-
|
|
3
|
+
"version": "0.2.2-dev-67ab902.0+67ab902",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "67ab9023ee52a0891fc152469b74a2bd623f0d6a"
|
|
41
41
|
}
|
package/src/debug.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["debug.js"],"names":[],"mappings":"AAOO,iCAHI,MAAM,WACN,OAAO,GAAG,SAAS,6BAiC7B"}
|
package/src/debug.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
let debugInstance = 1;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {string} name
|
|
6
|
+
* @param {boolean | 'verbose'} enable
|
|
7
|
+
*/
|
|
8
|
+
export const makeTracer = (name, enable = true) => {
|
|
9
|
+
debugInstance += 1;
|
|
10
|
+
let debugCount = 1;
|
|
11
|
+
const key = `----- ${name}.${debugInstance} `;
|
|
12
|
+
// the cases below define a named variable to provide better debug info
|
|
13
|
+
switch (enable) {
|
|
14
|
+
case false: {
|
|
15
|
+
const logDisabled = (..._args) => {};
|
|
16
|
+
return logDisabled;
|
|
17
|
+
}
|
|
18
|
+
case 'verbose': {
|
|
19
|
+
const infoTick = (optLog, ...args) => {
|
|
20
|
+
if (optLog.log) {
|
|
21
|
+
console.info(key, (debugCount += 1), ...args);
|
|
22
|
+
} else {
|
|
23
|
+
console.info(key, (debugCount += 1), optLog, ...args);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return infoTick;
|
|
27
|
+
}
|
|
28
|
+
default: {
|
|
29
|
+
const debugTick = (optLog, ...args) => {
|
|
30
|
+
if (optLog.log) {
|
|
31
|
+
optLog.log(key, (debugCount += 1), ...args);
|
|
32
|
+
} else {
|
|
33
|
+
console.info(key, (debugCount += 1), optLog, ...args);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return debugTick;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
harden(makeTracer);
|
package/src/index.d.ts
CHANGED