printCleanupDetails.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. Copyright 2018 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import { logger } from 'workbox-core/_private/logger.js';
  8. import '../_version.js';
  9. /**
  10. * @param {string} groupTitle
  11. * @param {Array<string>} deletedURLs
  12. *
  13. * @private
  14. */
  15. const logGroup = (groupTitle, deletedURLs) => {
  16. logger.groupCollapsed(groupTitle);
  17. for (const url of deletedURLs) {
  18. logger.log(url);
  19. }
  20. logger.groupEnd();
  21. };
  22. /**
  23. * @param {Array<string>} deletedURLs
  24. *
  25. * @private
  26. * @memberof module:workbox-precaching
  27. */
  28. export function printCleanupDetails(deletedURLs) {
  29. const deletionCount = deletedURLs.length;
  30. if (deletionCount > 0) {
  31. logger.groupCollapsed(`During precaching cleanup, ` +
  32. `${deletionCount} cached ` +
  33. `request${deletionCount === 1 ? ' was' : 's were'} deleted.`);
  34. logGroup('Deleted Cache Requests', deletedURLs);
  35. logger.groupEnd();
  36. }
  37. }