wireit
Version:
Upgrade your npm scripts to make them smarter and more efficient
43 lines • 1.27 kB
JavaScript
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { SimpleLogger } from './simple-logger.js';
import { inspect } from 'node:util';
// To prevent using the global console accidentally, we shadow it with
// undefined
const console = undefined;
function markAsUsed(_) { }
markAsUsed(console);
/**
* A {@link Logger} for logging debug information, mainly in tests.
*/
export class DebugLogger extends SimpleLogger {
log(event) {
switch (event.type) {
case 'info':
this.console.log(`<info> ${event.detail}`);
break;
case 'failure':
this.console.log(`<failure> ${event.reason}`);
break;
case 'output':
// too verbose, log nothing
return;
case 'success':
this.console.log(`<success> ${event.reason}`);
break;
default: {
const never = event;
throw new Error(`Unknown event type: ${inspect(never)}`);
}
}
super.log(event);
}
[Symbol.dispose]() {
super[Symbol.dispose]();
this.console[Symbol.dispose]();
}
}
//# sourceMappingURL=debug-logger.js.map