Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/utils/log-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ class LogFiles {
}
}
} catch (e) {
log.warn('logfile', 'error cleaning log files', e)
// Disable cleanup failure warnings when log writing is disabled
if (this.#logsMax > 0) {
log.warn('logfile', 'error cleaning log files', e)
}
} finally {
log.silly('logfile', 'done cleaning log files')
}
Expand Down
14 changes: 14 additions & 0 deletions test/lib/utils/log-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,20 @@ t.test('glob error', async t => {
t.match(last(logs).content, /error cleaning log files .* bad glob/)
})

t.test('do not log cleaning errors when logging is disabled', async t => {
const { readLogs } = await loadLogFile(t, {
logsMax: 0,
mocks: {
glob: () => {
throw new Error('should not be logged')
},
},
})

const logs = await readLogs()
t.equal(logs.length, 0)
})

t.test('cleans old style logs too', async t => {
const logsMax = 5
const oldLogs = 10
Expand Down