Skip to content

Commit

Permalink
Use Logger in Collector Cache Config
Browse files Browse the repository at this point in the history
Closes gh-41
  • Loading branch information
rwinch committed Aug 18, 2024
1 parent cc4a0f0 commit c0ffbcd
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/inject-collector-cache-config-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ module.exports.register = function ({ playbook, config = {} }) {
})
this.once('beforePublish', async () => {
for (const info of zipInfo) {
console.log(JSON.stringify(info))
await zip(fs, info.cacheDir, info.zipCacheFile)
await zip(fs, logger, info.cacheDir, info.zipCacheFile)
}
})
}
Expand Down Expand Up @@ -129,7 +128,7 @@ function createCachedCollectorConfig (scanDir, cacheDir) {
]
}

const zip = async function (fs, src, destination) {
const zip = async function (fs, logger, src, destination) {
const path = require('path')
const destParent = path.dirname(destination)
if (!fs.existsSync(destParent)) {
Expand All @@ -142,15 +141,15 @@ const zip = async function (fs, src, destination) {
// listen for all archive data to be written
// 'close' event is fired only when a file descriptor is involved
output.on('close', function () {
console.log(archive.pointer() + ' total bytes')
console.log('archiver has been finalized and the output file descriptor has closed.')
logger.info(archive.pointer() + ' total bytes')
logger.info('archiver has been finalized and the output file descriptor has closed.')
})

// This event is fired when the data source is drained no matter what was the data source.
// It is not part of this library but rather from the NodeJS Stream API.
// @see: https://nodejs.org/api/stream.html#stream_event_end
output.on('end', function () {
console.log('Data has been drained')
logger.info('Data has been drained')
})

// good practice to catch warnings (ie stat failures and other non-blocking errors)
Expand All @@ -175,5 +174,5 @@ const zip = async function (fs, src, destination) {

await archive.finalize()

console.log(`Saving ${src} into ${destination}`)
logger.info(`Saving ${src} into ${destination}`)
}

0 comments on commit c0ffbcd

Please sign in to comment.