Appearance
Variable: logger
ts
const logger: Logger;Defined in: packages/shared/lib/logger/index.d.ts:127
Logger management — configure filtering and create custom sub-loggers.
The SDK writes under three source tags — SDK, puppeteer and browser. Matching is case-insensitive, so 'sdk' and 'SDK' both work.
The SDK's internal subsystems tag their messages inline — [mw-renderer], [mw-chunking], [mw-groups] — and mute matches any substring, so a whole subsystem can be silenced with mute: ['[mw-renderer]'].
Examples
ts
import { logger } from '@matterway/sdk';
// Only show warnings and errors
logger.setConfig({ level: 'warn' });
// See the SDK's internal play-by-play (off by default)
logger.setConfig({ level: 'debug' });
// Drop one noisy source, keep everything else
logger.setConfig({ disabledSources: ['puppeteer'] });
// Only show logs from a specific source
logger.setConfig({ enabledSources: ['my-skill'] });
// Mute by any substring — a method name, a subsystem prefix, a phrase
logger.setConfig({ mute: ['retry', '[mw-renderer]'] });ts
import { logger } from '@matterway/sdk';
const log = logger.create('invoice-processor');
async function extractInvoiceData(ctx: Context) {
log.debug('extractInvoiceData: starting');
const total = await ctx.page.evaluate(() =>
document.querySelector('.total')?.textContent
);
log.debug('extractInvoiceData: got total', total);
return total;
}
// Mute a specific method
logger.setConfig({ mute: ['extractInvoiceData'] });