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

backupCount is not respected in TimedRotatingFileHandler when namer is specified #88916

Closed
alexandersmirnoff mannequin opened this issue Jul 27, 2021 · 6 comments
Closed
Labels
3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@alexandersmirnoff
Copy link
Mannequin

alexandersmirnoff mannequin commented Jul 27, 2021

BPO 44753
Nosy @vsajip, @miss-islington
PRs
  • bpo-44753: Don't use logfile extension when determining old files to … #27475
  • [3.9] bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) #27486
  • [3.10] bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) #27487
  • 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 = None
    closed_at = <Date 2021-07-30.16:22:12.730>
    created_at = <Date 2021-07-27.22:37:54.989>
    labels = ['library', '3.9', '3.10']
    title = 'backupCount is not respected in TimedRotatingFileHandler when namer is specified'
    updated_at = <Date 2021-07-30.16:22:12.729>
    user = 'https://bugs.python.org/alexandersmirnoff'

    bugs.python.org fields:

    activity = <Date 2021-07-30.16:22:12.729>
    actor = 'vinay.sajip'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-30.16:22:12.730>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2021-07-27.22:37:54.989>
    creator = 'alexander.smirnoff'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44753
    keywords = ['patch']
    message_count = 6.0
    messages = ['398326', '398537', '398538', '398568', '398569', '398570']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'miss-islington', 'alexander.smirnoff']
    pr_nums = ['27475', '27486', '27487']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44753'
    versions = ['Python 3.9', 'Python 3.10']

    @alexandersmirnoff
    Copy link
    Mannequin Author

    alexandersmirnoff mannequin commented Jul 27, 2021

    after adding namer callable (like it is described in https://bugs.python.org/issue43344) to log handler configuration, it stopped removing old files

    log_filename = os.path.join(log_dir, "application.log")
    log_handler = logging.handlers.TimedRotatingFileHandler(log_filename, when='MIDNIGHT', interval=1, backupCount=7)

    // after adding this line, old files are not deleted
    log_handler.namer = lambda name: name.replace(".log", "") + ".log"

    @alexandersmirnoff alexandersmirnoff mannequin added 3.8 only security fixes stdlib Python modules in the Lib dir labels Jul 27, 2021
    @vsajip
    Copy link
    Member

    vsajip commented Jul 30, 2021

    New changeset 6ff8903 by Vinay Sajip in branch 'main':
    bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475)
    6ff8903

    @vsajip
    Copy link
    Member

    vsajip commented Jul 30, 2021

    Should be fixed in main, leaving open until backports are done.

    @vsajip vsajip added 3.9 only security fixes 3.10 only security fixes and removed 3.8 only security fixes labels Jul 30, 2021
    @vsajip
    Copy link
    Member

    vsajip commented Jul 30, 2021

    New changeset 882e476 by Miss Islington (bot) in branch '3.9':
    bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) (GH-27486)
    882e476

    @vsajip
    Copy link
    Member

    vsajip commented Jul 30, 2021

    New changeset 6e6dc25 by Miss Islington (bot) in branch '3.10':
    bpo-44753: Don't use logfile extension when determining old files to be deleted (GH-27475) (GH-27487)
    6e6dc25

    @vsajip
    Copy link
    Member

    vsajip commented Jul 30, 2021

    Thanks for the bug report.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant