UNPKG

wireit

Version:

Upgrade your npm scripts to make them smarter and more efficient

41 lines 1.1 kB
/** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ // To prevent using the global console accidentally, we shadow it with // undefined const console = undefined; function markAsUsed(_) { } markAsUsed(console); /** * A {@link Logger} that logs to multiple loggers. */ export class CombinationLogger { #loggers; constructor(loggers, console) { this.console = console; this.#loggers = loggers; } log(event) { for (const logger of this.#loggers) { logger.log(event); } } printMetrics() { for (const logger of this.#loggers) { logger.printMetrics?.(); } } getWatchLogger() { const watchLoggers = this.#loggers.map((logger) => logger.getWatchLogger?.() ?? logger); return new CombinationLogger(watchLoggers, this.console); } [Symbol.dispose]() { for (const logger of this.#loggers) { logger[Symbol.dispose]?.(); } this.console[Symbol.dispose](); } } //# sourceMappingURL=combination-logger.js.map