@agoric/cosmic-swingset 0.41.4-dev-47470c7.0 → 0.41.4-dev-de9b2e7.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmic-swingset",
3
- "version": "0.41.4-dev-47470c7.0+47470c7",
3
+ "version": "0.41.4-dev-de9b2e7.0+de9b2e7",
4
4
  "description": "Agoric's Cosmos blockchain integration",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,15 +22,15 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/builders": "0.1.1-dev-47470c7.0+47470c7",
26
- "@agoric/cosmos": "0.34.2-dev-47470c7.0+47470c7",
27
- "@agoric/deploy-script-support": "0.10.4-dev-47470c7.0+47470c7",
28
- "@agoric/internal": "0.3.3-dev-47470c7.0+47470c7",
29
- "@agoric/store": "0.9.3-dev-47470c7.0+47470c7",
30
- "@agoric/swing-store": "0.9.2-dev-47470c7.0+47470c7",
31
- "@agoric/swingset-vat": "0.32.3-dev-47470c7.0+47470c7",
32
- "@agoric/telemetry": "0.6.3-dev-47470c7.0+47470c7",
33
- "@agoric/vm-config": "0.1.1-dev-47470c7.0+47470c7",
25
+ "@agoric/builders": "0.1.1-dev-de9b2e7.0+de9b2e7",
26
+ "@agoric/cosmos": "0.34.2-dev-de9b2e7.0+de9b2e7",
27
+ "@agoric/deploy-script-support": "0.10.4-dev-de9b2e7.0+de9b2e7",
28
+ "@agoric/internal": "0.3.3-dev-de9b2e7.0+de9b2e7",
29
+ "@agoric/store": "0.9.3-dev-de9b2e7.0+de9b2e7",
30
+ "@agoric/swing-store": "0.9.2-dev-de9b2e7.0+de9b2e7",
31
+ "@agoric/swingset-vat": "0.32.3-dev-de9b2e7.0+de9b2e7",
32
+ "@agoric/telemetry": "0.6.3-dev-de9b2e7.0+de9b2e7",
33
+ "@agoric/vm-config": "0.1.1-dev-de9b2e7.0+de9b2e7",
34
34
  "@endo/bundle-source": "^3.5.1",
35
35
  "@endo/env-options": "^1.1.8",
36
36
  "@endo/errors": "^1.2.9",
@@ -52,7 +52,7 @@
52
52
  "tmp": "^0.2.1"
53
53
  },
54
54
  "devDependencies": {
55
- "@agoric/kmarshal": "0.1.1-dev-47470c7.0+47470c7",
55
+ "@agoric/kmarshal": "0.1.1-dev-de9b2e7.0+de9b2e7",
56
56
  "ava": "^5.3.0",
57
57
  "better-sqlite3": "^9.1.1",
58
58
  "c8": "^10.1.2"
@@ -64,9 +64,17 @@
64
64
  "node": "^18.12 || ^20.9"
65
65
  },
66
66
  "ava": {
67
+ "extensions": {
68
+ "js": true,
69
+ "ts": "module"
70
+ },
67
71
  "files": [
68
72
  "test/**/*.test.*"
69
73
  ],
74
+ "nodeArguments": [
75
+ "--import=ts-blank-space/register",
76
+ "--no-warnings"
77
+ ],
70
78
  "require": [
71
79
  "@endo/init/debug.js"
72
80
  ],
@@ -75,5 +83,5 @@
75
83
  "typeCoverage": {
76
84
  "atLeast": 84.59
77
85
  },
78
- "gitHead": "47470c7d3999c1222677244ed29ce6fc60c7766f"
86
+ "gitHead": "de9b2e7ca244a6d131f2e4206aeee76f814382e4"
79
87
  }
@@ -4,68 +4,69 @@ import {
4
4
  getEnvironmentOption,
5
5
  } from '@endo/env-options';
6
6
  import anylogger from 'anylogger';
7
+ import { defineName } from '@agoric/internal/src/js-utils.js';
7
8
 
8
- // Turn on debugging output with DEBUG=agoric
9
+ /** @import {BaseLevels} from 'anylogger'; */
10
+ /** @typedef {keyof BaseLevels} LogLevel; */
9
11
 
10
- const DEBUG_LIST = getEnvironmentOptionsList('DEBUG');
12
+ const VAT_LOGGER_PREFIXES = Object.freeze([
13
+ 'SwingSet:vat',
14
+ 'SwingSet:ls', // "ls" for "liveslots"
15
+ ]);
11
16
 
12
- const isVatLogNameColon = nameColon =>
13
- ['SwingSet:ls:', 'SwingSet:vat:'].some(sel => nameColon.startsWith(sel));
17
+ const DEBUG_LIST = getEnvironmentOptionsList('DEBUG');
14
18
 
15
- // Turn on debugging output with DEBUG=agoric or DEBUG=agoric:${level}
16
- let selectedLevel =
17
- DEBUG_LIST.length || getEnvironmentOption('DEBUG', 'unset') === 'unset'
19
+ /**
20
+ * As documented in ../../../docs/env.md, the log level defaults to "log" when
21
+ * environment variable DEBUG is non-empty or unset, and to the quieter "info"
22
+ * when it is set to an empty string, but in either case is overridden if DEBUG
23
+ * is a comma-separated list that contains "agoric:none" or "agoric:${level}" or
24
+ * "agoric" (the last an alias for "agoric:debug").
25
+ *
26
+ * @type {string | undefined}
27
+ */
28
+ let maxActiveLevel =
29
+ DEBUG_LIST.length > 0 || getEnvironmentOption('DEBUG', 'unset') === 'unset'
18
30
  ? 'log'
19
31
  : 'info';
20
32
  for (const selector of DEBUG_LIST) {
21
- const parts = selector.split(':');
22
- if (parts[0] !== 'agoric') {
23
- continue;
24
- }
25
- if (parts.length > 1) {
26
- selectedLevel = parts[1];
27
- } else {
28
- selectedLevel = 'debug';
33
+ const fullSelector = selector === 'agoric' ? 'agoric:debug' : selector;
34
+ const [_, detail] = fullSelector.match(/^agoric:(.*)/gs) || [];
35
+ if (detail) {
36
+ maxActiveLevel = detail === 'none' ? undefined : detail;
29
37
  }
30
38
  }
31
- const selectedCode = anylogger.levels[selectedLevel];
32
- const globalCode = selectedCode === undefined ? -Infinity : selectedCode;
39
+ const maxActiveLevelCode = /** @type {number} */ (
40
+ (maxActiveLevel && anylogger.levels[maxActiveLevel]) ?? -Infinity
41
+ );
33
42
 
34
43
  const oldExt = anylogger.ext;
35
44
  anylogger.ext = logger => {
36
- const l = oldExt(logger);
37
- l.enabledFor = lvl => globalCode >= anylogger.levels[lvl];
45
+ logger = oldExt(logger);
38
46
 
39
- const prefix = l.name.replace(/:/g, ': ');
47
+ /** @type {(level: LogLevel) => boolean} */
48
+ const enabledFor = level => anylogger.levels[level] <= maxActiveLevelCode;
49
+ logger.enabledFor = enabledFor;
40
50
 
41
- const nameColon = `${l.name}:`;
42
- const logBelongsToVat = isVatLogNameColon(nameColon);
51
+ const nameColon = `${logger.name}:`;
52
+ const label = logger.name.replaceAll(':', ': ');
43
53
 
44
- // If this is a vat log, then it is enabled by a selector in DEBUG_LIST.
45
- const logMatchesSelector =
46
- !logBelongsToVat ||
47
- DEBUG_LIST.some(selector => {
48
- const selectorColon = `${selector}:`;
49
- return nameColon.startsWith(selectorColon);
50
- });
54
+ // Vat logs are suppressed unless matched by a prefix in DEBUG_LIST.
55
+ const suppressed =
56
+ VAT_LOGGER_PREFIXES.some(prefix => nameColon.startsWith(`${prefix}:`)) &&
57
+ !DEBUG_LIST.some(prefix => nameColon.startsWith(`${prefix}:`));
51
58
 
52
- for (const [level, code] of Object.entries(anylogger.levels)) {
53
- if (logMatchesSelector && globalCode >= code) {
54
- // Enable the printing with a prefix.
55
- const doLog = l[level];
56
- if (doLog) {
57
- l[level] = (...args) => {
58
- // Add a timestamp.
59
- const now = new Date().toISOString();
60
- doLog(`${now} ${prefix}:`, ...args);
61
- };
62
- } else {
63
- l[level] = () => {};
64
- }
65
- } else {
66
- // Disable printing.
67
- l[level] = () => {};
68
- }
59
+ const levels = /** @type {LogLevel[]} */ (Object.keys(anylogger.levels));
60
+ for (const level of levels) {
61
+ const impl = logger[level];
62
+ const disabled = !impl || suppressed || !enabledFor(level);
63
+ logger[level] = disabled
64
+ ? defineName(`dummy ${level}`, () => {})
65
+ : defineName(level, (...args) => {
66
+ // Prepend a timestamp and label.
67
+ const timestamp = new Date().toISOString();
68
+ impl(`${timestamp} ${label}:`, ...args);
69
+ });
69
70
  }
70
- return l;
71
+ return logger;
71
72
  };
@@ -318,6 +318,7 @@ export const makeHelpers = ({ db, EV }) => {
318
318
  stable: { db, getRefs, kvGet, kvGetJSON, kvGlob, vatsByID, vatsByName },
319
319
  });
320
320
  };
321
+ /** @typedef {ReturnType<typeof makeHelpers>} Helpers */
321
322
 
322
323
  /**
323
324
  * Wrap a swing-store sub-store (kvStore/transcriptStore/etc.) with a
package/tsconfig.json CHANGED
@@ -5,10 +5,10 @@
5
5
  "skipLibCheck": false
6
6
  },
7
7
  "include": [
8
- "calc-*.js",
9
- "src/**/*.js",
10
- "test/**/*.js",
11
8
  "*.cjs",
9
+ "*.js",
10
+ "src",
11
+ "test",
12
12
  "tools",
13
13
  ],
14
14
  }