public inbox for [email protected]help / color / mirror / Atom feed
Feature #6395 - Basic Log Rotation 4+ messages / 4 participants [nested] [flat]
* Feature #6395 - Basic Log Rotation @ 2021-04-16 17:29 Thomas Greenwood <[email protected]> 0 siblings, 2 replies; 4+ messages in thread From: Thomas Greenwood @ 2021-04-16 17:29 UTC (permalink / raw) To: [email protected] Hi, I've opened feature issue #6395 to enable log rotation in pgAdmin4 v5. Please find the attached basic patch as a starter for 10. It's the same patch attached to the feature issue. Thanks a lot, Tom Attachments: [text/x-diff] pgAdmin4-rotation.patch (1.3K, 3-pgAdmin4-rotation.patch) download | inline diff: diff -Naur orig/__init__.py new/__init__.py --- orig/__init__.py 2021-04-16 17:22:51.816949501 +0100 +++ new/__init__.py 2021-04-16 17:24:46.583081282 +0100 @@ -10,6 +10,7 @@ """The main pgAdmin module. This handles the application initialisation tasks, such as setup of logging, dynamic loading of modules etc.""" import logging +from logging.handlers import RotatingFileHandler import os import sys import re @@ -254,11 +255,17 @@ # Ensure the various working directories exist from pgadmin.setup import create_app_data_directory create_app_data_directory(config) + + if config.LOG_ROTATION_MAX_BYTES and config.LOG_ROTATION_NUM_BACKUPS: + # Rotated File logging + fh = RotatingFileHandler(config.LOG_FILE, mode='a', maxBytes=config.LOG_ROTATION_MAX_BYTES, backupCount=config.LOG_ROTATION_NUM_BACKUPS, encoding='utf-8', delay=False) + else: + # File logging + fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8') - # File logging - fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8') fh.setLevel(config.FILE_LOG_LEVEL) fh.setFormatter(logging.Formatter(config.FILE_LOG_FORMAT)) + app.logger.addHandler(fh) logger.addHandler(fh) ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Feature #6395 - Basic Log Rotation @ 2021-04-19 16:31 COG Internet <[email protected]> parent: Thomas Greenwood <[email protected]> 1 sibling, 1 reply; 4+ messages in thread From: COG Internet @ 2021-04-19 16:31 UTC (permalink / raw) To: [email protected] Hi, I have a version 2 of this with a fixed conditional and initial config values which I'll send through later today. Thanks, Tom On 19 April 2021 17:17:30 Thomas Greenwood <[email protected]> wrote: > Hi, > I've opened feature issue #6395 to enable log rotation in pgAdmin4 v5. > Please find the attached basic patch as a starter for 10. It's the same > patch attached to the feature issue. > Thanks a lot, > Tom ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Feature #6395 - Basic Log Rotation @ 2021-04-20 10:23 Dave Page <[email protected]> parent: Thomas Greenwood <[email protected]> 1 sibling, 0 replies; 4+ messages in thread From: Dave Page @ 2021-04-20 10:23 UTC (permalink / raw) To: Thomas Greenwood <[email protected]>; +Cc: pgadmin-hackers <[email protected]> Hi On Mon, Apr 19, 2021 at 5:17 PM Thomas Greenwood <[email protected]> wrote: > Hi, > > I've opened feature issue #6395 to enable log rotation in pgAdmin4 v5. > > Please find the attached basic patch as a starter for 10. It's the same > patch attached to the feature issue. > Nice! My only suggestions would be that the config options be added to config.py, with default values of zero for log size, and say, 5 for the number of backups (should that be 'archives'?), and that we test to see if the log size is > 0 before enabling rotation. The reason for that is that we keep all config options in config.py to ensure it's self-documenting. -- Dave Page Blog: https://pgsnake.blogspot.com Twitter: @pgsnake EDB: https://www.enterprisedb.com ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Feature #6395 - Basic Log Rotation @ 2021-04-29 06:52 Akshay Joshi <[email protected]> parent: COG Internet <[email protected]> 0 siblings, 0 replies; 4+ messages in thread From: Akshay Joshi @ 2021-04-29 06:52 UTC (permalink / raw) To: COG Internet <[email protected]>; +Cc: pgadmin-hackers <[email protected]> Hi Tom On Tue, Apr 20, 2021 at 3:56 PM COG Internet <[email protected]> wrote: > Hi, > > I have a version 2 of this with a fixed conditional and initial config > values which I'll send through later today. > Have you worked on this? If patch is ready can you please send it. > > Thanks, > > Tom > > On 19 April 2021 17:17:30 Thomas Greenwood <[email protected]> wrote: > >> Hi, >> >> I've opened feature issue #6395 to enable log rotation in pgAdmin4 v5. >> >> Please find the attached basic patch as a starter for 10. It's the same >> patch attached to the feature issue. >> >> Thanks a lot, >> >> Tom >> > > -- *Thanks & Regards* *Akshay Joshi* *pgAdmin Hacker | Principal Software Architect* *EDB Postgres <http://edbpostgres.com>* *Mobile: +91 976-788-8246* ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-04-29 06:52 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-04-16 17:29 Feature #6395 - Basic Log Rotation Thomas Greenwood <[email protected]> 2021-04-19 16:31 ` COG Internet <[email protected]> 2021-04-29 06:52 ` Akshay Joshi <[email protected]> 2021-04-20 10:23 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox