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

Specifying the time a TimedRotatingFileHandler rotates #53765

Closed
ronaldoussoren opened this issue Aug 10, 2010 · 7 comments
Closed

Specifying the time a TimedRotatingFileHandler rotates #53765

ronaldoussoren opened this issue Aug 10, 2010 · 7 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@ronaldoussoren
Copy link
Contributor

BPO 9556
Nosy @vsajip, @ronaldoussoren, @merwok
Files
  • issue9556.txt
  • updated-patch.diff: Added weekly test, docs to Ronald's patch
  • post-comments.diff: Taking Ronald's comments into account
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/vsajip'
    closed_at = <Date 2013-04-12.16:04:35.234>
    created_at = <Date 2010-08-10.11:57:35.214>
    labels = ['type-feature', 'library']
    title = 'Specifying the time a TimedRotatingFileHandler rotates'
    updated_at = <Date 2013-04-12.16:04:35.232>
    user = 'https://github.com/ronaldoussoren'

    bugs.python.org fields:

    activity = <Date 2013-04-12.16:04:35.232>
    actor = 'python-dev'
    assignee = 'vinay.sajip'
    closed = True
    closed_date = <Date 2013-04-12.16:04:35.234>
    closer = 'python-dev'
    components = ['Library (Lib)']
    creation = <Date 2010-08-10.11:57:35.214>
    creator = 'ronaldoussoren'
    dependencies = []
    files = ['27667', '27687', '27693']
    hgrepos = ['156']
    issue_num = 9556
    keywords = ['patch']
    message_count = 7.0
    messages = ['113527', '113565', '114693', '173587', '173639', '173678', '186648']
    nosy_count = 5.0
    nosy_names = ['vinay.sajip', 'ronaldoussoren', 'eric.araujo', 'tshepang', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue9556'
    versions = ['Python 3.4']

    @ronaldoussoren
    Copy link
    Contributor Author

    The logging module contains a TimedRotatingFileHandler that automaticly rotates the logfile after a specified interval.

    This class misses an important feature: it is not possible to specify at what time the file should be rotated, unless that time is midnight.

    My usecase: one of our customers works night shifts which means that rotating logfiles at midnight means that files get rotated halfway through a shift instead of at the end of one.

    We'd like to be able to specify that logfiles get rotated at a specific time (such as 7:00AM).

    @ronaldoussoren ronaldoussoren added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Aug 10, 2010
    @merwok
    Copy link
    Member

    merwok commented Aug 10, 2010

    Adding the logging maintainer to nosy. (BTW Vinay, Misc/maintainers.rst says your roundup name is “vsajip”)

    @vsajip
    Copy link
    Member

    vsajip commented Aug 22, 2010

    One way of implementing this is to use an additional optional "atTime" parameter which is a datetime.time instance, defaulting to None; a specified value would only be used if a 'when' value of 'D' or 'MIDNIGHT' were specified. In that case, computeRollover would be called with the specified time instead of the current time.

    Would that meet your requirements?

    @vsajip vsajip self-assigned this Aug 22, 2010
    @ronaldoussoren
    Copy link
    Contributor Author

    An 'atTime' argument would work. I'm currently using a subclass of BaseRotatingHandler that implements just the 'MIDNIGHT' option of TimedRotatingFileHandler with a rotation hour argument.

    The attached patch is a first attempt at implementing the 'atTime' option, it is currently lacking documentation and tests for the 'WEEKLY' value for 'when'.

    @vsajip
    Copy link
    Member

    vsajip commented Oct 23, 2012

    Thanks for the patch. I've added the weekly test and the documentation update, can you take a look?

    @vsajip
    Copy link
    Member

    vsajip commented Oct 24, 2012

    Thanks for the comments on Rietveld - patch updated.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 12, 2013

    New changeset eead4be1bdd9 by Vinay Sajip in branch 'default':
    Closed bpo-9556: Allowed specifying a time-of-day for a TimedRotatingFileHandler to rotate.
    http://hg.python.org/cpython/rev/eead4be1bdd9

    @python-dev python-dev mannequin closed this as completed Apr 12, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants