File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,10 @@ class LogFiles {
223223 }
224224 }
225225 } catch ( e ) {
226- log . warn ( 'logfile' , 'error cleaning log files' , e )
226+ // Disable cleanup failure warnings when log writing is disabled
227+ if ( this . #logsMax > 0 ) {
228+ log . warn ( 'logfile' , 'error cleaning log files' , e )
229+ }
227230 } finally {
228231 log . silly ( 'logfile' , 'done cleaning log files' )
229232 }
Original file line number Diff line number Diff line change @@ -255,6 +255,20 @@ t.test('glob error', async t => {
255255 t . match ( last ( logs ) . content , / e r r o r c l e a n i n g l o g f i l e s .* b a d g l o b / )
256256} )
257257
258+ t . test ( 'do not log cleaning errors when logging is disabled' , async t => {
259+ const { readLogs } = await loadLogFile ( t , {
260+ logsMax : 0 ,
261+ mocks : {
262+ glob : ( ) => {
263+ throw new Error ( 'should not be logged' )
264+ } ,
265+ } ,
266+ } )
267+
268+ const logs = await readLogs ( )
269+ t . equal ( logs . length , 0 )
270+ } )
271+
258272t . test ( 'cleans old style logs too' , async t => {
259273 const logsMax = 5
260274 const oldLogs = 10
You can’t perform that action at this time.
0 commit comments