From 771f99b18d76060f030d36b5fa619dd41a7000c8 Mon Sep 17 00:00:00 2001 From: Piotr Grzesik Date: Mon, 11 Oct 2021 14:12:25 +0200 Subject: [PATCH] refactor(CLI): Adapt `logInfo` to modern logs --- lib/classes/PromiseTracker.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/classes/PromiseTracker.js b/lib/classes/PromiseTracker.js index 1e15942d7..e86537fe7 100644 --- a/lib/classes/PromiseTracker.js +++ b/lib/classes/PromiseTracker.js @@ -1,6 +1,7 @@ 'use strict'; const logInfo = require('./Error').logInfo; +const { log } = require('@serverless/utils/log'); const constants = { pending: 'pending', @@ -38,6 +39,19 @@ class PromiseTracker { ]) .join('\n ') ); + log.info( + [ + '############################################################################################', + `# ${delta}: ${this.getSettled().length} of ${this.getAll().length} promises have settled`, + `# ${delta}: ${pending.length} are taking longer than expected:`, + ] + .concat(pending.map((promise) => `# ${delta}: ${promise.waitList}`)) + .concat([ + '# This can result from latent connections but may represent a cyclic variable dependency', + '##########################################################################################', + ]) + .join('\n ') + ); this.reported = true; } stop() { @@ -54,6 +68,17 @@ class PromiseTracker { '##########################################################################################', ].join('\n ') ); + log.info( + [ + '############################################################################################', + `# Completed after ${Date.now() - this.startTime}ms`, + `# ${this.getAll().length} promises are in the following states:`, + `# ${constants.resolved}: ${this.getResolved().length}`, + `# ${constants.rejected}: ${this.getRejected().length}`, + `# ${constants.pending}: ${this.getPending().length}`, + '##########################################################################################', + ].join('\n ') + ); } this.reset(); }