wireit
Version:
Upgrade your npm scripts to make them smarter and more efficient
38 lines • 1.08 kB
JavaScript
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import '../util/dispose.js';
import { Console as NodeConsole } from 'node:console';
// To prevent using the global console accidentally, we shadow it with
// undefined
const console = undefined;
function markAsUsed(_) { }
markAsUsed(console);
export class Console extends NodeConsole {
#closeStreams;
#closed = false;
constructor(stdout, stderr, closeStreams = false) {
super(stdout, stderr);
this.stdout = stdout;
this.stderr = stderr;
this.#closeStreams = closeStreams;
}
[Symbol.dispose]() {
if (this.#closed) {
return;
}
this.#closed = true;
if (this.#closeStreams) {
this.stdout.end();
this.stderr.end();
}
}
}
/**
* When true, we're debugging the logger itself, so a logger should log with
* more verbosity, and not overwrite previously written lines.
*/
export const DEBUG = Boolean(process.env['WIREIT_DEBUG_LOGGER']);
//# sourceMappingURL=logger.js.map