iccicci / rotating-file-stream

Opens a stream.Writable to a file rotated by interval and/or size. A logrotate alternative.
MIT License
286 stars 39 forks source link

Custom compressed file names #93

Closed Ciph3r-Zer0 closed 1 year ago

Ciph3r-Zer0 commented 1 year ago

I've read the docs but could not find any reference on how can we change naming convention on the compressed files Currently It generates something like this '20230709-0108-01-app.log.gz' Bbut I want to change it

iccicci commented 1 year ago

Hi @Ciph3r-Zer0 ,

it seems when you read the docs you've missed the filename paragraph 😉

If you use a string, the default filename generator function is used, otherwise you can provide your own filename generator function to completely customize the generated file names.

If this helps, please feel free to close this issue.

Ciph3r-Zer0 commented 1 year ago

Hello, thanks for replying yes this solves my problem, but why is there 2 file.log files in the directory now? The first file is called file.log which is the current log file But the second file is called file.log.txt which contains the path for compressed files like this: logs\1402-02-19_23-46-00_1.log.gz logs\1402-02-19_23-46-05_1.log.gz logs\1402-02-19_23-46-10_1.log.gz logs\1402-02-19_23-46-15_1.log.gz logs\1402-02-19_23-46-20_1.log.gz logs\1402-02-19_23-46-25_1.log.gz logs\1402-02-19_23-46-30_1.log.gz logs\1402-02-19_23-46-35_1.log.gz

iccicci commented 1 year ago

Hi @Ciph3r-Zer0 ,

it seems the .txt file is the history file; if you use maxFiles or maxSize that file contains the history of the files to check to respect the limits.

Its name can be customized through the history option.

Ciph3r-Zer0 commented 1 year ago

Yeap, it worked. Thanks