Skip to content

Commit f3e6d6d

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 e6702e5 commit f3e6d6d

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

pgcli/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,21 @@ def initialize_logging(self):
574574
# Use TimedRotatingFileHandler for daily log rotation
575575
# Rotates at midnight, keeps 30 days of logs
576576
expanded_log_file = os.path.expanduser(log_file)
577+
578+
# Remove .log extension if present to avoid pgcli.log.log pattern
579+
base_log_file = expanded_log_file
580+
if base_log_file.endswith('.log'):
581+
base_log_file = base_log_file[:-4]
582+
577583
handler = logging.handlers.TimedRotatingFileHandler(
578-
expanded_log_file,
584+
base_log_file,
579585
when='midnight',
580586
interval=1,
581587
backupCount=30,
582588
encoding='utf-8'
583589
)
584-
# Format: pgcli.log.2025-12-02
585-
handler.suffix = "%Y-%m-%d"
590+
# Format: pgcli.YYYY-MM-DD.log
591+
handler.suffix = ".%Y-%m-%d.log"
586592

587593
level_map = {
588594
"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)