Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Changelog

All notable changes to Canopy are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---

## [Unreleased]

### Added

- Comprehensive performance benchmark suite (15 tests)
- Crash recovery integration tests (12 tests)
- GitHub Actions CI/CD workflow
- SwiftLint configuration with code quality rules
- Platform-aware lock implementation
- Documentation for testing and CI/CD

### Changed

- `formatMessage()`: Optimized to use single-pass counting instead of `components(separatedBy:)`
- `Tree.tag()`: Fixed race condition by reading and clearing atomically
- `Canopy.log()`: Eliminated code duplication, consolidated two log method overloads

### Fixed

- Thread safety issues with `explicitTag` in concurrent scenarios
- Code duplication in Canopy.swift (reduced from 169 to 138 lines)
- SwiftLint violations across the codebase

### Performance

- Format message performance improved by ~10%
- Added performance benchmarks for all critical paths
- Zero-overhead logging verified in Release mode

---

## [0.1.0] - 2026-01-08

### Added

- Core logging framework with Tree-based architecture
- DebugTree for console logging
- CrashBufferTree for crash recovery
- AsyncTree for background logging
- Tagged logging support via `Canopy.tag()`
- Context support via `CanopyContext`
- Demo application with interactive examples
- Comprehensive test suite (60 tests)
- Multi-language documentation (English/Chinese)

### Features

- **Tree Architecture**: Flexible pluggable logging trees
- **Zero-overhead Release**: DebugTree optimized out in Release builds
- **String Formatting**: C-style format specifiers (`%@`, `%d`, etc.)
- **Thread Safety**: Lock-protected concurrent access
- **iOS 14+ Support**: Pure Swift standard library implementation

### Documentation

- README.md with quick start and best practices
- TESTING.md with test suite documentation
- CONTRIBUTING.md with contribution guidelines
- Examples/README.md with integration examples

---

## Version History

| Version | Date | Status |
|---------|------|--------|
| [Unreleased] | - | In development |
| [0.1.0] | 2026-01-08 | Initial release |

---

## Migration Guides

### Upgrading from 0.1.0

No breaking changes in unreleased version. API remains fully backward compatible.

### Migration Checklist

1. Update dependency version in `Package.swift` or `Podfile`
2. Review new API additions if needed
3. Run test suite to verify compatibility

---

## Release Schedule

Canopy follows a flexible release schedule:

- **Patch releases**: As needed for bug fixes
- **Minor releases**: Monthly for new features and improvements
- **Major releases**: As needed for breaking changes

---

## Acknowledgments

- Inspired by [Timber](https://github.com/JakeWharton/Timber) (Android)
- Performance benchmarks based on industry best practices
- Swift community for language design and best practices
217 changes: 211 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Thank you for your interest in contributing to Canopy!

---

## How to Contribute

### Reporting Bugs
Expand All @@ -28,34 +30,237 @@ Enhancement suggestions are welcome! Please:
1. Fork the repository
2. Create a branch for your feature (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Run tests if available
5. Commit your changes (`git commit -m 'Add some amazing feature'`)
6. Push to the branch (`git push origin feature/amazing-feature`)
7. Create a Pull Request
4. Run tests (`swift test`)
5. Run SwiftLint (`swiftlint`)
6. Commit your changes (`git commit -m 'Add some amazing feature'`)
7. Push to the branch (`git push origin feature/amazing-feature`)
8. Create a Pull Request

---

## Code Review Guidelines

### Before Submitting

- [ ] All tests pass (`swift test`)
- [ ] SwiftLint passes (`swiftlint`)
- [ ] No new warnings introduced
- [ ] Benchmark tests pass (if applicable)
- [ ] Documentation updated
- [ ] CHANGELOG.md updated

## Code Style
### Pull Request Checklist

- Follow Swift API Design Guidelines
- [ ] Code follows project conventions
- [ ] Tests added/updated for new functionality
- [ ] Benchmarks added for performance changes
- [ ] Documentation updated
- [ ] CHANGELOG.md updated with changes
- [ ] CI passes

### Code Style

- Follow [Swift API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/)
- Use meaningful variable and function names
- Add comments for complex logic
- Maintain existing formatting
- Run SwiftLint before submitting

### Commit Message Format

```
<type>(<scope>): <subject>

<body>

<footer>
```

**Types:**
- `feat`: New feature
- `fix`: Bug fix
- `perf`: Performance improvement
- `docs`: Documentation only
- `test`: Adding or modifying tests
- `refactor`: Code restructuring
- `chore`: Maintenance tasks

**Example:**
```
feat(Tree): improve explicitTag thread safety

- Fix race condition by reading and clearing atomically
- Add benchmark tests for performance verification

Closes #123
```

---

## Development Setup

### Prerequisites

- macOS 14.0+ or iOS 14.0+ deployment target
- Swift 5.0+
- Xcode 15.0+

### Getting Started

```bash
# Clone the repository
git clone https://github.com/ding1dingx/Canopy.git
cd Canopy

# Open in Xcode
open Canopy.xcodeproj

# Or use Swift Package Manager
swift package generate-xcodeproj
open Canopy.xcodeproj
```

### Running Tests

```bash
# All tests
swift test

# Specific test suite
swift test --filter CanopyTests

# With code coverage
swift test --enable-code-coverage
```

### Running Benchmarks

```bash
# Performance benchmarks
swift test --filter CanopyBenchmarkTests

# Crash recovery tests
swift test --filter CanopyCrashRecoveryTests
```

### Code Quality

```bash
# Install SwiftLint
brew install swiftlint

# Run linting
swiftlint

# Auto-fix issues
swiftlint --autocorrect
```

---

## Testing

### Test Requirements

- Test on iOS 14.0+ simulators
- Test on physical devices if possible
- Test both Debug and Release configurations
- Run performance benchmarks for performance changes

### Test Coverage

Canopy maintains comprehensive test coverage:

- **87 unit and integration tests**
- **15 performance benchmarks**
- **12 crash recovery tests**

All tests must pass before merging.

---

## Release Process

### Version Bump

1. Update version in `Package.swift`
2. Update CHANGELOG.md with new version
3. Create git tag (`git tag v0.2.0`)
4. Push tag (`git push origin v0.2.0`)

### Release Checklist

- [ ] All tests pass
- [ ] Benchmark tests pass
- [ ] Documentation updated
- [ ] CHANGELOG.md updated
- [ ] Version bumped in Package.swift
- [ ] Git tag created
- [ ] Release notes prepared

### Release Notes Format

```markdown
## v0.2.0

### New Features
- Feature description

### Bug Fixes
- Fixed issue description

### Performance
- Performance improvement details

### Breaking Changes
- Migration guide if applicable
```

---

## Project Structure

```
Canopy/
β”œβ”€β”€ Canopy/
β”‚ β”œβ”€β”€ Sources/
β”‚ β”‚ β”œβ”€β”€ Tree.swift # Base class
β”‚ β”‚ β”œβ”€β”€ Canopy.swift # Main API
β”‚ β”‚ β”œβ”€β”€ LogLevel.swift # Log levels
β”‚ β”‚ β”œβ”€β”€ AsyncTree.swift # Async wrapper
β”‚ β”‚ β”œβ”€β”€ CrashBufferTree.swift # Crash recovery
β”‚ β”‚ β”œβ”€β”€ DebugTree.swift # Console output
β”‚ β”‚ β”œβ”€β”€ CanopyContext.swift # Context support
β”‚ β”‚ └── Lock.swift # Lock utilities
β”‚ └── Canopy/ # App delegate, etc.
β”œβ”€β”€ CanopyTests/ # Test files
β”‚ β”œβ”€β”€ CanopyTests.swift
β”‚ β”œβ”€β”€ TreeTests.swift
β”‚ β”œβ”€β”€ AsyncTreeTests.swift
β”‚ β”œβ”€β”€ DebugTreeTests.swift
β”‚ β”œβ”€β”€ CrashBufferTreeTests.swift
β”‚ β”œβ”€β”€ CanopyBenchmarkTests.swift # Performance benchmarks
β”‚ └── CanopyCrashRecoveryTests.swift
β”œβ”€β”€ Examples/ # Example integrations
β”‚ β”œβ”€β”€ XLogTree.swift
β”‚ β”œβ”€β”€ SentryTree.swift
β”‚ └── RemoteLogTree.swift
β”œβ”€β”€ .github/workflows/ # CI/CD
β”œβ”€β”€ TESTING.md # Testing guide
β”œβ”€β”€ CONTRIBUTING.md # This file
β”œβ”€β”€ README.md # Main documentation
└── Package.swift # SPM manifest
```

---

## Communication

- **Issues**: Use GitHub Issues for bugs and feature requests
- **Discussions**: Use GitHub Discussions for questions and ideas
- **Pull Requests**: For code contributions

---

## License

Expand Down
Loading