Enhancement: Configurable Log and Data Retention #5
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: nick/753-Data-Sync#5
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Enhance the 753 Data Sync script to dynamically name the log file based on the current date and purge old log/data files based on an environment variable (
PURGE_DAYS). This feature will improve log file management and ensure old files are deleted automatically.Proposed Behavior
Dynamically Name Log Files: The log file should be named based on the current date in the format
753DataSync_YYYY-MM-DD.log. This will prevent overwriting of log files and allow better organization of logs over time.Purge Old Files: Upon script startup, the script will check the environment variable
PURGE_DAYSand delete any logs or data files older than the specified number of days. This will ensure that outdated logs and data do not accumulate in thedatafolder or current directory.New Environment Variables
PURGE_DAYSdatafolder (for JSON files) and the current directory (for.logfiles). Default is 30 days.Behavioral Details
753DataSync_YYYY-MM-DD.log, whereYYYY-MM-DDrepresents the current date.PURGE_DAYSenvironment variable. If this variable is set, the script will delete files in thedatafolder and any.logfiles in the current directory that are older than the specified number of days.Implementation Notes
datetime.now().strftime("%Y-%m-%d").datafolder (for.jsonfiles) and in the current directory (for.logfiles). Files older than the specifiedPURGE_DAYSwill be deleted.PURGE_DAYS: If the environment variable is not set, the default is 30 days.Benefits
Example Usage
To dynamically name the log file based on the current date, simply ensure that the
log_filenameis set as shown in the implementation:To purge old files, set the
PURGE_DAYSenvironment variable to the desired number of days (e.g.,5days). The script will automatically delete files older than this value:Implementation Example
Here’s a code snippet for the purge functionality:
This has been merged into master.