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

Feature request: exposing function to force rotate #92

Open
ipetrovic11 opened this issue Jun 26, 2022 · 3 comments
Open

Feature request: exposing function to force rotate #92

ipetrovic11 opened this issue Jun 26, 2022 · 3 comments

Comments

@ipetrovic11
Copy link

This is a feature request.

Currently, there is no easy way to force rotation.

The logic for the new rotation can be packed in one nice function and exposed so rotation can happen from the outside.

@rogerc
Copy link
Owner

rogerc commented Oct 30, 2022

Hi @ipetrovic11

I've just rewritten the module in Typescript making it more modular. What would be the expected behaviour?

I can only see this working easily if size based rotation is used.

Let me now if this Is what you had in mind and I'll add it to v1.

@ipetrovic11
Copy link
Author

Here is the use case:

Let's say a batch of logs should be uploaded to the centralized location. It is unsafe to process a file that is currently. It would be great to have a function that will force the use of the next(incremented counter) so that all the logs that were previously created until that moment can be uploaded.

I don't remember what kind of API there exists, but for this use case .rotate() or .forceRotate() that would switch from:
testlog-2017-03-07.13.10.log.1
to
testlog-2017-03-07.13.10.log.2

@rogerc
Copy link
Owner

rogerc commented Oct 31, 2022

@ipetrovic11 I've made a change to force a log rotation. The parameter is a boolean that decides if to force the log rotation or not. Default is false. If called without true it will have the normal behaviour.

rotatingLogStream.rotate(true)

https://github.com/rogerc/file-stream-rotator/tree/v1

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

No branches or pull requests

2 participants