You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable the deletion of old log files after X log files have been created. (#50)
* Enable deletion of old files when maxsize option is not set
This change enables the transport to delete old files when maxsize has not been configured.
This functionality uses the maxfiles property to determine how many files are kept and will delete files that exceed this limit beginning with the oldest. During start up the transport will check the log directory for any files that contain the the _basename used by it and will save these filenames to an internal variable. These files will count towards the maxfiles limit.
Example.
The daily rotating file transport for the error level uses a MM-dd date pattern, prepends this pattern to the file name and has maxfiles set to 3. On the 2nd of Jan the transport starts and discovers a file already exists in the log directory for the 1st of Jan and proceeds to create a file for the 2nd of Jan e.g.
01-01.error.log
01-02.error.log
While creating the log file for the 4th of Jan the transport realizes it has hit its max file limit and so deletes the 01-01.error.log file leaving the log directory with the following contents.
01-02.error.log
01-03.error.log
01-04.error.log
This functionality will not be enabled if the maxsize property has been configured for the transport.
* Update _currentFiles initialization function
Update the function that initializes the internal _currentFiles variable to ensure the filenames are returned in chronological order.
* fixing linting issues
* Adding tests for new functionality
Tests added to ensure file rotation and file deletion behaves as expected when maxsize is not set but maxfiles is.
* Remove use of fs.accessSync
Removed the uses of fs.accessSync as they are not available in older versions of Node and were breaking the Travis Integration tests.
0 commit comments