Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rolling log file when reaches certain size #80

Open
avnerbarr opened this issue Jun 20, 2021 · 2 comments
Open

rolling log file when reaches certain size #80

avnerbarr opened this issue Jun 20, 2021 · 2 comments

Comments

@avnerbarr
Copy link

I saw a similar question about truncating log, but I want to create a new log file once reaches 20MB or some other metric (keeping the previous).

is there a way to achieve this?

@cavivie
Copy link

cavivie commented Aug 9, 2022

I also need this feature. Have you implemented this feature?

@daboross
Copy link
Owner

This hasn't been implemented, no. It wouldn't be the biggest change, but it hasn't been done!

To add this, we really just need to copy the DateBasedConfig implementation in log_impl.rs (https://github.com/daboross/fern/blob/main/src/log_impl.rs#L169-L261) and builders.rs (https://github.com/daboross/fern/blob/main/src/builders.rs#L541-L565), replacing DateBased with SizeBased and rotating in log_impl based on total size rather than date. A simple test like https://github.com/daboross/fern/blob/0ef6202750e9854e619b279a3ac33904bc5a82a4/examples/date-based-file-log.rs would be ideal too, but beyond that, just follow the compiler errors.

Tests as well would be ideal, but the base should be pretty simple. I've just not implemented that yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants