Skip to content

feat: add log rotation support#8

Merged
devfeel merged 6 commits intodevelopfrom
aicode
Mar 16, 2026
Merged

feat: add log rotation support#8
devfeel merged 6 commits intodevelopfrom
aicode

Conversation

@devfeel
Copy link
Owner

@devfeel devfeel commented Mar 16, 2026

feat: add log rotation support

Add log rotation functionality for FileTarget and JSONTarget with configurable backup cleanup.

Changes

New Features

  • targets/rotator.go - New file with rotation implementations
    • SizeRotator: Size-based rotation with automatic backup cleanup
    • TimeRotator: Time-based rotation support
  • JSONTarget - Implemented rotation support (previously missing)
  • FileTarget - Fixed concurrency issue with mutex protection

Configuration

Added maxBackups option:

targets:
  file:
    - name: FileLogger
      fileMaxSize: 10240
      maxBackups: 5
  json:
    - name: JSONLogger
      fileMaxSize: 10240
      maxBackups: 5

Bug Fixes

  • Fixed FileTarget concurrent write issue with sync.Mutex
  • Fixed directory creation order
  • Added error handling

Version

Updated to 0.10.1

Test Results

Item Status
Build Pass
Test Pass
Lint Pass

PR: #7

root and others added 6 commits March 16, 2026 10:15
- Update Version in const/const.go
- Add version history in version.md
- Add rotator.go with SizeRotator and TimeRotator
- Add rotation support to JSONTarget
- Fix FileTarget concurrency issue with mutex
- Add MaxBackups config option for file cleanup
- Add sync.Mutex to protect file write operations

Features:
- Size-based rotation with automatic backup cleanup
- Time-based rotation support
- Configurable max backup files to keep
- Check rotator.Rotate error return
- Check os.MkdirAll error return
- Add example/rotation/ with rotation demo
- Add rotation.yaml config with file rotation settings
- Demonstrate both FileTarget and JSONTarget rotation
- Update version in const/const.go
- Add version history in version.md
feat: add log rotation support
@devfeel devfeel merged commit 26dbd5c into develop Mar 16, 2026
2 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.

1 participant