Skip to content

Commit

Permalink
feat(cosmic-swingset): $SLOGFILE will make the chain write a slogfile
Browse files Browse the repository at this point in the history
Run e.g. `SLOGFILE=/path/to/chain.slog agoric start local-chain` to cause the
chain's kernel to write "slog" (swingset log) entries to the named file.
Relative pathnames are probably interpreted against the current working
directory. Shortcuts using `~` are unlikely to work unless expanded before
setting the environment variable. The parent directory must exist when the
kernel starts.

We must sadly pass this as an environment variable because the command-line
arguments are consumed by the cosmos-sdk Go code. I hope we can fix that some
day.
  • Loading branch information
warner committed Apr 16, 2021
1 parent 209b034 commit c845132
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/cosmic-swingset/lib/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default async function main(
noFakeCurrencies: env.NO_FAKE_CURRENCIES,
};
const meterProvider = getMeterProvider(console, env);
const slogFile = env.SLOGFILE;
const s = await launch(
stateDBDir,
mailboxStorage,
Expand All @@ -238,6 +239,7 @@ export default async function main(
argv,
undefined,
meterProvider,
slogFile,
);
return s;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/cosmic-swingset/lib/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function buildSwingset(
storage,
vatsDir,
argv,
{ debugName = undefined, slogCallbacks },
{ debugName = undefined, slogCallbacks, slogFile },
) {
const debugPrefix = debugName === undefined ? '' : `${debugName}:`;
let config = loadSwingsetConfigFile(`${vatsDir}/chain-config.json`);
Expand Down Expand Up @@ -76,6 +76,7 @@ async function buildSwingset(
await ensureSwingsetInitialized();
const controller = await makeSwingsetController(storage, deviceEndowments, {
slogCallbacks,
slogFile,
});

// We DON'T want to run the kernel yet, only when the application decides
Expand All @@ -92,6 +93,7 @@ export async function launch(
argv,
debugName = undefined,
meterProvider = DEFAULT_METER_PROVIDER,
slogFile = undefined,
) {
console.info('Launching SwingSet kernel');

Expand All @@ -118,6 +120,7 @@ export async function launch(
{
debugName,
slogCallbacks,
slogFile,
},
);

Expand Down

0 comments on commit c845132

Please sign in to comment.