Skip to content

Commit

Permalink
fix: make default log level for ag-chain-cosmos more compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 19, 2020
1 parent 2cf5cd8 commit 258e4c9
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions packages/SwingSet/src/devices/command-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function setup(syscall, state, helpers, endowments) {
const body = JSON.parse(`${bodyString}`);
SO(inboundHandler).inbound(Nat(count), body);
} catch (e) {
console.log(`error during inboundCallback: ${e}`);
console.error(`error during inboundCallback:`, e);
throw new Error(`error during inboundCallback: ${e}`);
}
});
Expand All @@ -36,15 +36,15 @@ export default function setup(syscall, state, helpers, endowments) {
try {
deliverResponse(count, isReject, JSON.stringify(obj));
} catch (e) {
console.log(`error during sendResponse: ${e}`);
console.error(`error during sendResponse:`, e);
}
},

sendBroadcast(obj) {
try {
sendBroadcast(JSON.stringify(obj));
} catch (e) {
console.log(`error during sendBroadcast: ${e}`);
console.error(`error during sendBroadcast:`, e);
}
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function buildCommand(broadcastCallback) {
try {
inboundCallback(count, JSON.stringify(obj));
} catch (e) {
console.log(`error running inboundCallback: ${e}`);
console.error(`error running inboundCallback:`, e);
}
return p;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/inbound-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function setup(syscall, state, helpers, endowments) {
try {
SO(inboundHandler).inbound(`${sender}`, `${message}`);
} catch (e) {
console.log(`error during inboundCallback: ${e}`);
console.error(`error during inboundCallback:`, e);
}
};
return harden({
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/devices/mailbox-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function setup(syscall, state, helpers, endowments) {
try {
SO(inboundHandler).deliverInboundMessages(peer, newMessages);
} catch (e) {
console.log(`error during deliverInboundMessages: ${e}`);
console.error(`error during deliverInboundMessages: ${e}`, e);
}
};

Expand All @@ -73,7 +73,7 @@ export default function setup(syscall, state, helpers, endowments) {
try {
SO(inboundHandler).deliverInboundAck(peer, ack);
} catch (e) {
console.log(`error during deliverInboundAck: ${e}`);
console.error(`error during deliverInboundAck:`, e);
}
};

Expand Down
9 changes: 5 additions & 4 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default function buildKernel(kernelEndowments) {
await vat.manager.deliverOneMessage(target, msg);
} catch (e) {
// log so we get a stack trace
console.log(`error in kernel.deliver:`, e);
console.error(`error in kernel.deliver:`, e);
throw e;
}
}
Expand Down Expand Up @@ -359,7 +359,7 @@ export default function buildKernel(kernelEndowments) {
await vat.manager.deliverOneNotification(kpid, p);
} catch (e) {
// log so we get a stack trace
console.log(`error in kernel.processNotify:`, e);
console.error(`error in kernel.processNotify:`, e);
throw e;
}
}
Expand All @@ -368,7 +368,7 @@ export default function buildKernel(kernelEndowments) {
async function processQueueMessage(message) {
kdebug(`processQ ${JSON.stringify(message)}`);
if (processQueueRunning) {
console.log(`We're currently already running at`, processQueueRunning);
console.error(`We're currently already running at`, processQueueRunning);
throw Error(`Kernel reentrancy is forbidden`);
}
try {
Expand Down Expand Up @@ -494,7 +494,7 @@ export default function buildKernel(kernelEndowments) {
if (drefs.has(val)) {
return drefs.get(val);
}
console.log(`oops ${val}`, val);
console.error(`oops ${val}`, val);
throw Error('bootstrap got unexpected pass-by-presence');
}

Expand Down Expand Up @@ -692,6 +692,7 @@ export default function buildKernel(kernelEndowments) {

// if it *was* initialized, replay the transcripts
if (wasInitialized) {
console.info('Replaying SwingSet transcripts');
const oldLength = kernelKeeper.getRunQueueLength();
for (const vatID of ephemeral.vats.keys()) {
console.log(`Replaying transcript of vatID ${vatID}`);
Expand Down
7 changes: 5 additions & 2 deletions packages/SwingSet/src/kernel/state/storageWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function guardStorage(hostStorage) {
try {
return hostStorage[method](...args);
} catch (err) {
console.log(`error invoking hostStorage.${method}(${args})`, err);
console.error(`error invoking hostStorage.${method}(${args})`, err);
throw new Error(`error invoking hostStorage.${method}(${args}): ${err}`);
}
}
Expand All @@ -57,7 +57,10 @@ export function guardStorage(hostStorage) {
yield `${key}`;
}
} catch (err) {
console.log(`error invoking hostStorage.getKeys(${start}, ${end})`, err);
console.error(
`error invoking hostStorage.getKeys(${start}, ${end})`,
err,
);
throw new Error(
`error invoking hostStorage.getKeys(${start}, ${end}): ${err}`,
);
Expand Down
3 changes: 2 additions & 1 deletion packages/cosmic-swingset/lib/ag-chain-cosmos
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ const path = require('path');
const agcc = require('bindings')('agcosmosdaemon.node');
const esmRequire = require('esm')(module);

esmRequire('./agoric-anylogger');
esmRequire('./anylogger-agoric');
const anylogger = require('anylogger');

const log = anylogger('ag-chain-cosmos');

const main = esmRequire('./chain-main.js').default;
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/anylogger-agoric.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import anylogger from 'anylogger';
// Turn on debugging output with DEBUG=agoric

const debugging = process.env.DEBUG && process.env.DEBUG.includes('agoric');
const defaultLevel = debugging ? anylogger.levels.debug : anylogger.levels.info;
const defaultLevel = debugging ? anylogger.levels.debug : anylogger.levels.log;

const oldExt = anylogger.ext;
anylogger.ext = (l, o) => {
Expand Down
1 change: 1 addition & 0 deletions packages/cosmic-swingset/lib/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ async function buildSwingset(withSES, mailboxState, storage, vatsDir, argv) {

export async function launch(kernelStateDBDir, mailboxStorage, vatsDir, argv) {
const withSES = true;
log.info('Launching SwingSet kernel');

log(`checking for saved mailbox state`, mailboxStorage.has('mailbox'));
const mailboxState = mailboxStorage.has('mailbox')
Expand Down

0 comments on commit 258e4c9

Please sign in to comment.