@mbsks/rspfx-diagnostics
v0.0.13
Published
RSPFX diagnostics: logger, typed errors, benchmarks, formatting
Readme
@mbsks/rspfx-diagnostics
Diagnostics for RSPFX — an SPFx-compatible build toolchain powered by Rspack.
Structured logging, typed errors, benchmarks, and formatting helpers shared across the toolchain and CLI.
Install
npm i @mbsks/rspfx-diagnosticsUsage
import { createLogger, RspfxError, formatBytes, reportBenchmark, timeStart } from '@mbsks/rspfx-diagnostics';
const log = createLogger({ level: 'info' });
log.info('building %s', 'my-webpart');
try {
// ...
} catch (cause) {
throw new RspfxError('E1001', 'something failed', cause);
}
const elapsed = timeStart();
// ... work ...
reportBenchmark('my-step', elapsed());
console.log(formatBytes(1_500_000)); // "1.4 MB"API
createLogger(opts)/Logger/LogLevel— structured logger (level fromRSPFX_LOG_LEVELenv var)RspfxError— typed error with code, message, and causereportBenchmark,timeStart,trace— timing/telemetryformatBytes— human-readable byte sizes
Links
- RSPFX documentation
- License: MIT
