Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import type { Logger } from '@metamask/logger';
import type { VatPowers } from '@metamask/ocap-kernel';
/**
* Powers provided to test vats that need structured logging.
* Extends VatPowers to maintain type compatibility with production vat powers.
*/
export type TestPowers = VatPowers & {
logger: Logger;
};
/**
* Extract a tlog function from test vat powers.
*
* @param powers - The vat powers containing a logger.
* @param name - The vat name to include in log tags.
* @returns A function that logs with 'test' and name tags.
*/
export function unwrapTestLogger(
powers: TestPowers,
name: string,
): (message: string, ...args: unknown[]) => void {
const logger = powers.logger.subLogger({ tags: ['test', name] });
return (message: string, ...args: unknown[]): void =>
logger.log(message, ...args);
}
|