Skip to content

Commit 19a51cc

Browse files
DiegoDAFclaude
andcommitted
fix: change log rotation format to pgcli.YYYY-MM-DD.log
Changed the log file rotation format from pgcli.log.YYYY-MM-DD to pgcli.YYYY-MM-DD.log for better file naming conventions. Changes: - pgcli/main.py: Updated suffix format and added logic to strip .log extension - pgcli/pgclirc: Updated documentation to reflect new format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 71698f3 commit 19a51cc

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pgcli/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,21 @@ def initialize_logging(self):
561561
# Use TimedRotatingFileHandler for daily log rotation
562562
# Rotates at midnight, keeps 30 days of logs
563563
expanded_log_file = os.path.expanduser(log_file)
564+
565+
# Remove .log extension if present to avoid pgcli.log.log pattern
566+
base_log_file = expanded_log_file
567+
if base_log_file.endswith('.log'):
568+
base_log_file = base_log_file[:-4]
569+
564570
handler = logging.handlers.TimedRotatingFileHandler(
565-
expanded_log_file,
571+
base_log_file,
566572
when='midnight',
567573
interval=1,
568574
backupCount=30,
569575
encoding='utf-8'
570576
)
571-
# Format: pgcli.log.2025-12-02
572-
handler.suffix = "%Y-%m-%d"
577+
# Format: pgcli.YYYY-MM-DD.log
578+
handler.suffix = ".%Y-%m-%d.log"
573579

574580
level_map = {
575581
"CRITICAL": logging.CRITICAL,

pgcli/pgclirc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ alias_map_file =
7070
# - Tries /var/log/pgcli/pgcli.log first (if running with permissions)
7171
# - Falls back to ~/.config/pgcli/log (Unix/Linux) or %USERPROFILE%\AppData\Local\dbcli\pgcli\log (Windows)
7272
# Log rotation: Daily at midnight, keeps 30 days of logs
73-
# Format: pgcli.log.YYYY-MM-DD
73+
# Format: pgcli.YYYY-MM-DD.log
7474
# You can specify a custom path here if needed
7575
log_file = default
7676

0 commit comments

Comments
 (0)