diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 349d9ec..69e2092 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,61 +1,634 @@ -# Contributing Guidelines +# Contributing to Log -This document contains information and guidelines about contributing to this project. -Please read it before you start participating. +First off, thank you for considering contributing to Log! It's people like you that make Log such a great tool. -**Topics** +## Table of Contents -* [Reporting Issues](#reporting-issues) -* [Submitting Pull Requests](#submitting-pull-requests) -* [Developers Certificate of Origin](#developers-certificate-of-origin) -* [Code of Conduct](#code-of-conduct) +- [Code of Conduct](#code-of-conduct) +- [Getting Started](#getting-started) + - [Development Setup](#development-setup) + - [Project Structure](#project-structure) +- [How Can I Contribute?](#how-can-i-contribute) + - [Reporting Bugs](#reporting-bugs) + - [Suggesting Features](#suggesting-features) + - [Improving Documentation](#improving-documentation) + - [Submitting Code](#submitting-code) +- [Development Workflow](#development-workflow) + - [Branching Strategy](#branching-strategy) + - [Commit Guidelines](#commit-guidelines) + - [Pull Request Process](#pull-request-process) +- [Coding Standards](#coding-standards) + - [Swift Style Guide](#swift-style-guide) + - [Code Quality](#code-quality) + - [Testing Requirements](#testing-requirements) +- [Community](#community) -## Reporting Issues +## Code of Conduct -A great way to contribute to the project is to send a detailed issue when you encounter a problem. We always appreciate a well-written, thorough bug report. +This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to nv3212@gmail.com. -Check that the project issues database doesn't already include that problem or suggestion before submitting an issue. If you find a match, feel free to vote for the issue by adding a reaction. Doing this helps prioritize the most common problems and requests. +See [CODE_OF_CONDUCT.md](https://github.com/space-code/log/blob/main/CODE_OF_CONDUCT.md) for details. -When reporting issues, please fill out our issue template. The information the template asks for will help us review and fix your issue faster. +## Getting Started -## Submitting Pull Requests +### Development Setup -You can contribute by fixing bugs or adding new features. For larger code changes, we recommend first discussing your ideas on our [GitHub Discussions](https://github.com/space-code/log/discussions). When submitting a pull request, please add relevant tests and ensure your changes don't break any existing tests. +1. **Fork the repository** + ```bash + # Click the "Fork" button on GitHub + ``` -## Developer's Certificate of Origin 1.1 +2. **Clone your fork** + ```bash + git clone https://github.com/YOUR_USERNAME/log.git + cd log + ``` -By making a contribution to this project, I certify that: +3. **Set up the development environment** + ```bash + # Bootstrap the project + make bootstrap + ``` -- (a) The contribution was created in whole or in part by me and I - have the right to submit it under the open source license - indicated in the file; or +4. **Create a feature branch** + ```bash + git checkout -b feature/your-feature-name + ``` -- (b) The contribution is based upon previous work that, to the best - of my knowledge, is covered under an appropriate open source - license and I have the right under that license to submit that - work with modifications, whether created in whole or in part - by me, under the same open source license (unless I am - permitted to submit under a different license), as indicated - in the file; or +5. **Open the project in Xcode** + ```bash + open Package.swift + ``` -- (c) The contribution was provided directly to me by some other - person who certified (a), (b) or (c) and I have not modified - it. +## How Can I Contribute? -- (d) I understand and agree that this project and the contribution - are public and that a record of the contribution (including all - personal information I submit with it, including my sign-off) is - maintained indefinitely and may be redistributed consistent with - this project or the open source license(s) involved. +### Reporting Bugs -## Code of Conduct +Before creating a bug report, please check the [existing issues](https://github.com/space-code/log/issues) to avoid duplicates. + +When creating a bug report, include: + +- **Clear title** - Describe the issue concisely +- **Reproduction steps** - Detailed steps to reproduce the bug +- **Expected behavior** - What you expected to happen +- **Actual behavior** - What actually happened +- **Environment** - OS, Xcode version, Swift version +- **Code samples** - Minimal reproducible example +- **Error messages** - Complete error output if applicable + +**Example:** +```markdown +**Title:** TimestampLogFormatter produces incorrect date format + +**Steps to reproduce:** +1. Create TimestampLogFormatter with custom date format +2. Log a message with the formatter +3. Observe the timestamp output + +**Expected:** Timestamp should use the specified format "yyyy-MM-dd" +**Actual:** Timestamp uses default format "HH:mm:ss" + +**Environment:** +- iOS 16.0 +- Xcode 14.3 +- Swift 5.7 + +**Code:** +\`\`\`swift +let formatter = TimestampLogFormatter(dateFormat: "yyyy-MM-dd") +let printer = ConsolePrinter(formatters: [formatter]) +let log = Logger(printers: [printer], logLevel: .all) +log.info(message: "Test") +// Expected: ℹ️ 2024-01-15 => Test +// Actual: ℹ️ 14:30:45 => Test +\`\`\` +``` + +### Suggesting Features + +We love feature suggestions! When proposing a new feature, include: + +- **Problem statement** - What problem does this solve? +- **Proposed solution** - How should it work? +- **Alternatives** - What alternatives did you consider? +- **Use cases** - Real-world scenarios +- **API design** - Example code showing usage +- **Breaking changes** - Will this break existing code? + +**Example:** +```markdown +**Feature:** Add JSON formatter for structured logging + +**Problem:** Current formatters produce plain text, making it difficult to parse logs programmatically or integrate with log aggregation services. + +**Solution:** Add JSONLogFormatter that outputs logs in structured JSON format. + +**API:** +\`\`\`swift +let formatter = JSONLogFormatter( + includeTimestamp: true, + includeLevel: true, + additionalFields: ["environment": "production"] +) + +let printer = ConsolePrinter(formatters: [formatter]) +let log = Logger(printers: [printer], logLevel: .all) +log.info(message: "User logged in") + +// Output: {"level":"info","timestamp":"2024-01-15T14:30:45Z","message":"User logged in","environment":"production"} +\`\`\` + +**Use case:** Mobile apps that send logs to centralized logging services like Elasticsearch or Splunk. +``` + +### Improving Documentation + +Documentation improvements are always welcome: + +- **Code comments** - Add/improve inline documentation +- **DocC documentation** - Enhance documentation articles +- **README** - Fix typos, add examples +- **Guides** - Write tutorials or how-to guides +- **API documentation** - Document public APIs + +### Submitting Code -The Code of Conduct governs how we behave in public or in private -whenever the project will be judged by our actions. -We expect it to be honored by everyone who contributes to this project. +1. **Check existing work** - Look for related issues or PRs +2. **Discuss major changes** - Open an issue for large features +3. **Follow coding standards** - See [Coding Standards](#coding-standards) +4. **Write tests** - All code changes require tests +5. **Update documentation** - Keep docs in sync with code +6. **Create a pull request** - Use clear description -See [CODE_OF_CONDUCT.md](https://github.com/space-code/log/blob/master/CODE_OF_CONDUCT.md) for details. +## Development Workflow + +### Branching Strategy + +We use a simplified branching model: + +- **`main`** - Main development branch (all PRs target this) +- **`feature/*`** - New features +- **`fix/*`** - Bug fixes +- **`docs/*`** - Documentation updates +- **`refactor/*`** - Code refactoring +- **`test/*`** - Test improvements + +**Branch naming examples:** +```bash +feature/json-formatter +fix/timestamp-formatter-timezone +docs/update-formatter-guide +refactor/simplify-printer-protocol +test/add-logger-edge-cases +``` + +### Commit Guidelines + +We use [Conventional Commits](https://www.conventionalcommits.org/) for clear, structured commit history. + +**Format:** +``` +(): + + + +