import { statSync } from 'fs' ; /**
 * Context shared between the rolling file manager, policy and strategy.
 */ export class RollingFileContext { constructor ( public readonly filePath ) { } /**
     * The size of the currently opened file.
     */ public currentFileSize : number = 0 ; /**
     * The time the currently opened file was created.
     */ public currentFileTime : number = 0 ; public refreshFileInfo ( ) { try { const { birthtime , size } = statSync ( this . filePath ) ; this . currentFileTime = birthtime . getTime ( ) ; this . currentFileSize = size ; } catch ( e ) { if ( e . code !== 'ENOENT' ) { console . error ( '[RollingFileAppender] error accessing the log file' , e ) ; } this . currentFileTime = Date . now ( ) ; this . currentFileSize = 0 ; } } }