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

Allow for combining file rotation triggers by accepting a list of rotation conditions #1174

Closed
CollinHeist opened this issue Jul 15, 2024 · 1 comment
Labels
enhancement Improvement to an already existing feature

Comments

@CollinHeist
Copy link
Contributor

CollinHeist commented Jul 15, 2024

Background

I found myself (and others) wanting to rotate log files based on a combination of two already-implemented conditions (file size and interval in my case). I see there is existing functionality to allow arbitrary logic in the rotation by passing in a generic callable, however that would have required me to re-implement much of loguru's existing rotator functionality (or import code from within the loguru source).

A cleaner approach would be to permit the specification of lists (or generic iterables) in the rotation argument, and then have loguru parse each element into a combined rotation rotation logic where a file will be rotated if any of the rotators evaluate to true.

Example

from loguru import logger

logger.configure(
  handlers=[
    dict(
      sink='file.log',
      rotation=['12h', '10 MB'],
    )
  ]
)

Would rotate log files every 12 hours or every 10 Megabytes. This is much easier for the end-user than creating a custom callable of the same logic.

I've submitted this PR

@Delgan Delgan added feature Request for adding a new feature enhancement Improvement to an already existing feature and removed feature Request for adding a new feature labels Sep 22, 2024
@Delgan
Copy link
Owner

Delgan commented Jan 17, 2025

Fixed by #1175.

@Delgan Delgan closed this as completed Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an already existing feature
Projects
None yet
Development

No branches or pull requests

2 participants