Skip to content

Commit

Permalink
fix(anylogger): coherent DEBUG levels, $DEBUG always says more
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jan 25, 2022
1 parent 32554df commit 5e482fe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
6 changes: 3 additions & 3 deletions packages/agoric-cli/src/anylogger-agoric.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import anylogger from 'anylogger';
import chalk from 'chalk';

// Turn on debugging output with DEBUG=agoric

const { DEBUG } = process.env;
let selectedLevel = 'info';
if (process.env.DEBUG === undefined) {
if (DEBUG === undefined) {
selectedLevel = 'log';
} else if (process.env.DEBUG.includes('agoric')) {
} else if (DEBUG.includes('agoric')) {
selectedLevel = 'debug';
}
const defaultLevel = anylogger.levels[selectedLevel];
Expand Down
16 changes: 8 additions & 8 deletions packages/agoric-cli/src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export default async function startMain(progname, rawArgs, powers, opts) {
const SOLO_IMAGE = `agoric/cosmic-swingset-solo:${opts.dockerTag}`;

const pspawnEnv = { ...process.env };
if (opts.verbose > 1) {
// Loudly verbose logs (nondeterministic).
pspawnEnv.DEBUG = 'agoric,SwingSet:vat,SwingSet:ls';
} else if (opts.verbose) {
// Verbose vat logs (nondeterministic).
pspawnEnv.DEBUG = 'SwingSet:vat,SwingSet:ls';
}

const pspawn = makePspawn({ env: pspawnEnv, spawn, log, chalk });

// Turn on some debugging options.
Expand Down Expand Up @@ -686,14 +694,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {

const popts = opts;

if (popts.verbose > 1) {
// Enable verbose logs.
pspawnEnv.DEBUG = 'agoric';
} else if (!popts.verbose) {
// Disable more logs.
pspawnEnv.DEBUG = '';
}

const args = rawArgs.slice(1);
const profileName = args[0] || 'dev';
const startFn = profiles[profileName];
Expand Down
33 changes: 18 additions & 15 deletions packages/cosmic-swingset/src/anylogger-agoric.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@ import anylogger from 'anylogger';

// Turn on debugging output with DEBUG=agoric

const { DEBUG: debugEnv = '' } = process.env;
let debugging;

const filterOutPrefixes = [];
// Mute vat logging unless requested, for determinism.
if (!debugEnv.includes('SwingSet:vat')) {
filterOutPrefixes.push('SwingSet:vat:');
}
// Mute liveSlots logging unless requested, for determinism.
if (!debugEnv.includes('SwingSet:ls')) {
filterOutPrefixes.push('SwingSet:ls:');
}

if (process.env.DEBUG === undefined) {
// DEBUG not set, default to log level.
debugging = 'log';
// DEBUG wasn't set, default to info level; quieter than normal.
debugging = 'info';
} else if (debugEnv.includes('agoric')) {
// $DEBUG set and we're enabled; loudly verbose.
debugging = 'debug';
} else {
if (!process.env.DEBUG.includes('SwingSet:vat')) {
filterOutPrefixes.push('SwingSet:vat:');
}
if (!process.env.DEBUG.includes('SwingSet:ls')) {
filterOutPrefixes.push('SwingSet:ls:');
}
if (process.env.DEBUG.includes('agoric')) {
// DEBUG set and we're enabled; verbose.
debugging = 'debug';
} else {
// DEBUG set but we're not enabled; quieter than normal.
debugging = 'info';
}
// $DEBUG set but we're not enabled; slightly louder than normal.
debugging = 'log';
}
const defaultLevel = anylogger.levels[debugging];

Expand Down

0 comments on commit 5e482fe

Please sign in to comment.