Skip to content

Comments

Logger クラスに欠落していた compressOldLogs/deleteOldLogs メソッドを追加#396

Merged
yama merged 3 commits intofeature/refactor-log-systemfrom
copilot/sub-pr-393-another-one
Feb 7, 2026
Merged

Logger クラスに欠落していた compressOldLogs/deleteOldLogs メソッドを追加#396
yama merged 3 commits intofeature/refactor-log-systemfrom
copilot/sub-pr-393-another-one

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

ExecPlan 内の Logger クラス例で compressOldLogs()deleteOldLogs() メソッドが参照されているが、クラス定義に存在しなかった。CLI サンプルおよび autoCleanup() 内部呼び出しが動作するようメソッドを実装。

追加したメソッド

  • compressOldLogs($days = 7): 指定日数以上経過したログを gzip 圧縮

    • 戻り値: ['count', 'before_size', 'after_size', 'saved_size', 'ratio'] (MB 単位)
    • log:compress CLI と autoCleanup() で使用
  • deleteOldLogs($days, $dryRun = false): 保持期間超過ログを削除

    • $dryRun = true でプレビューモード(削除せず対象リスト返却)
    • 戻り値: ['count', 'size', 'files'] (MB 単位)
    • log:clean CLI と autoCleanup() で使用
  • compressDirectory() / collectOldFiles(): 上記メソッドの補助関数

使用例

// CLI: log:compress
$logger = new Logger();
$result = $logger->compressOldLogs(7);
echo "圧縮: {$result['count']}件, {$result['saved_size']} MB 削減 ({$result['ratio']}%)\n";

// CLI: log:clean --dry-run
$result = $logger->deleteOldLogs(30, true);
echo "削除対象: {$result['count']}件 ({$result['size']} MB)\n";
foreach ($result['files'] as $file) {
    echo "  - {$file}\n";
}

// 内部: autoCleanup()
$this->compressOldLogs(7);
$this->deleteOldLogs($days);  // 戻り値未使用

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 7, 2026 15:05
Co-authored-by: yama <73999+yama@users.noreply.github.com>
Co-authored-by: yama <73999+yama@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on manager log refactor plan Logger クラスに欠落していた compressOldLogs/deleteOldLogs メソッドを追加 Feb 7, 2026
Copilot AI requested a review from yama February 7, 2026 15:07
@yama yama marked this pull request as ready for review February 7, 2026 15:09
@yama yama merged commit 737f30e into feature/refactor-log-system Feb 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants