tinystructlog 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. tinystructlog-0.1.2/.editorconfig +24 -0
  2. tinystructlog-0.1.2/.github/workflows/docs.yml +36 -0
  3. tinystructlog-0.1.2/.github/workflows/publish.yml +47 -0
  4. tinystructlog-0.1.2/.github/workflows/test.yml +45 -0
  5. tinystructlog-0.1.2/.gitignore +78 -0
  6. tinystructlog-0.1.2/.readthedocs.yaml +20 -0
  7. tinystructlog-0.1.2/CHANGELOG.md +47 -0
  8. tinystructlog-0.1.2/CONTRIBUTING.md +139 -0
  9. tinystructlog-0.1.2/LICENSE +21 -0
  10. tinystructlog-0.1.2/MANIFEST.in +26 -0
  11. tinystructlog-0.1.2/PKG-INFO +308 -0
  12. tinystructlog-0.1.2/PUBLISHING.md +326 -0
  13. tinystructlog-0.1.2/QUICK_REFERENCE.md +315 -0
  14. tinystructlog-0.1.2/README.md +271 -0
  15. tinystructlog-0.1.2/docs/api.rst +52 -0
  16. tinystructlog-0.1.2/docs/comparison.rst +139 -0
  17. tinystructlog-0.1.2/docs/conf.py +70 -0
  18. tinystructlog-0.1.2/docs/examples.rst +533 -0
  19. tinystructlog-0.1.2/docs/index.rst +68 -0
  20. tinystructlog-0.1.2/docs/quickstart.rst +296 -0
  21. tinystructlog-0.1.2/examples/async_context.py +72 -0
  22. tinystructlog-0.1.2/examples/basic_usage.py +39 -0
  23. tinystructlog-0.1.2/examples/web_framework.py +122 -0
  24. tinystructlog-0.1.2/pyproject.toml +123 -0
  25. tinystructlog-0.1.2/src/tinystructlog/__init__.py +51 -0
  26. tinystructlog-0.1.2/src/tinystructlog/core.py +289 -0
  27. tinystructlog-0.1.2/src/tinystructlog/py.typed +0 -0
  28. tinystructlog-0.1.2/tests/__init__.py +1 -0
  29. tinystructlog-0.1.2/tests/test_context.py +184 -0
  30. tinystructlog-0.1.2/tests/test_formatting.py +306 -0
  31. tinystructlog-0.1.2/tests/test_logger.py +293 -0
  32. tinystructlog-0.1.2/uv.lock +1176 -0
@@ -0,0 +1,24 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.py]
12
+ indent_style = space
13
+ indent_size = 4
14
+ max_line_length = 100
15
+
16
+ [*.{yml,yaml}]
17
+ indent_style = space
18
+ indent_size = 2
19
+
20
+ [*.{md,rst}]
21
+ trim_trailing_whitespace = false
22
+
23
+ [Makefile]
24
+ indent_style = tab
@@ -0,0 +1,36 @@
1
+ name: Documentation
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ build-docs:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: '3.12'
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ pip install -e ".[dev]"
26
+
27
+ - name: Build documentation
28
+ run: |
29
+ cd docs
30
+ sphinx-build -W -b html . _build/html
31
+
32
+ - name: Upload documentation artifacts
33
+ uses: actions/upload-artifact@v4
34
+ with:
35
+ name: documentation
36
+ path: docs/_build/html
@@ -0,0 +1,47 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ build-and-publish:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: '3.12'
24
+
25
+ - name: Install build dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install build twine
29
+
30
+ - name: Build package
31
+ run: python -m build
32
+
33
+ - name: Check package
34
+ run: twine check dist/*
35
+
36
+ - name: Publish to PyPI
37
+ uses: pypa/gh-action-pypi-publish@release/v1
38
+ with:
39
+ password: ${{ secrets.PYPI_API_TOKEN }}
40
+
41
+ - name: Create GitHub Release
42
+ uses: softprops/action-gh-release@v1
43
+ with:
44
+ files: dist/*
45
+ generate_release_notes: true
46
+ body: |
47
+ See [CHANGELOG.md](https://github.com/Aprova-GmbH/tinystructlog/blob/main/CHANGELOG.md) for details.
@@ -0,0 +1,45 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install -e ".[dev]"
29
+
30
+ - name: Run linters
31
+ run: |
32
+ black --check src tests
33
+ ruff check src tests
34
+
35
+ - name: Run tests with coverage
36
+ run: |
37
+ pytest --cov=contexlog --cov-report=xml --cov-report=term-missing
38
+
39
+ - name: Upload coverage to Codecov
40
+ uses: codecov/codecov-action@v4
41
+ if: matrix.python-version == '3.12'
42
+ with:
43
+ file: ./coverage.xml
44
+ fail_ci_if_error: false
45
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,78 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # PyInstaller
29
+ *.manifest
30
+ *.spec
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+
36
+ # Unit test / coverage reports
37
+ htmlcov/
38
+ .tox/
39
+ .nox/
40
+ .coverage
41
+ .coverage.*
42
+ .cache
43
+ nosetests.xml
44
+ coverage.xml
45
+ *.cover
46
+ .hypothesis/
47
+ .pytest_cache/
48
+
49
+ # Virtual environments
50
+ venv/
51
+ ENV/
52
+ env/
53
+ .venv/
54
+
55
+ # IDEs
56
+ .vscode/
57
+ .idea/
58
+ *.swp
59
+ *.swo
60
+ *~
61
+ .DS_Store
62
+
63
+ # Sphinx documentation
64
+ docs/_build/
65
+ docs/_static/
66
+ docs/_templates/
67
+
68
+ # MyPy
69
+ .mypy_cache/
70
+ .dmypy.json
71
+ dmypy.json
72
+
73
+ # Ruff
74
+ .ruff_cache/
75
+
76
+ # Build artifacts
77
+ *.whl
78
+ *.tar.gz
@@ -0,0 +1,20 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ version: 2
5
+
6
+ build:
7
+ os: ubuntu-22.04
8
+ tools:
9
+ python: "3.12"
10
+
11
+ sphinx:
12
+ configuration: docs/conf.py
13
+ fail_on_warning: false
14
+
15
+ python:
16
+ install:
17
+ - method: pip
18
+ path: .
19
+ extra_requirements:
20
+ - dev
@@ -0,0 +1,47 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.2] - 2026-01-18
9
+
10
+ ### Added
11
+ - Documentation update: added comparison with loguru
12
+
13
+ ## [0.1.1] - 2026-01-18
14
+
15
+ ### Added
16
+ - Custom log format support via `fmt` and `datefmt` parameters in `get_logger()`
17
+ - Preset format constants: `MINIMAL_FORMAT`, `DETAILED_FORMAT`, `SIMPLE_FORMAT`
18
+ - Exported `DEFAULT_FORMAT` and `DEFAULT_DATEFMT` constants for reference
19
+ - Comprehensive examples for custom formats in README and documentation
20
+
21
+ ### Changed
22
+ - Documentation now explicitly states that v0.1.0 had an opinionated, hardcoded format
23
+ - Enhanced API documentation with custom format examples and usage patterns
24
+
25
+ ### Note
26
+ - **Fully backward compatible** - default behavior unchanged from v0.1.0
27
+ - Calling `get_logger(__name__)` without parameters produces identical output to v0.1.0
28
+
29
+ ## [0.1.0] - 2024-01-17
30
+
31
+ ### Added
32
+ - Initial release of contexlog
33
+ - Core context management with `set_log_context()`, `clear_log_context()`, and `log_context()`
34
+ - Context-aware logger creation with `get_logger()`
35
+ - Thread-safe and async-safe context isolation using `contextvars`
36
+ - Colored terminal output with `ColoredFormatter`
37
+ - Context injection via `ContextFilter`
38
+ - Zero runtime dependencies
39
+ - Full type hints support (PEP 561)
40
+ - Comprehensive test suite with >90% coverage
41
+ - Documentation and examples
42
+ - MIT license
43
+
44
+
45
+ [0.1.2]: https://github.com/vykhand/tinystructlog/compare/v0.1.1...v0.1.2
46
+ [0.1.1]: https://github.com/vykhand/tinystructlog/compare/v0.1.0...v0.1.1
47
+ [0.1.0]: https://github.com/vykhand/tinystructlog/releases/tag/v0.1.0
@@ -0,0 +1,139 @@
1
+ # Contributing to contexlog
2
+
3
+ Thank you for your interest in contributing to contexlog! This document provides guidelines and instructions for contributing.
4
+
5
+ ## Code of Conduct
6
+
7
+ This project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
8
+
9
+ ## How to Contribute
10
+
11
+ ### Reporting Bugs
12
+
13
+ If you find a bug, please create an issue on GitHub with:
14
+ - A clear, descriptive title
15
+ - Steps to reproduce the issue
16
+ - Expected vs. actual behavior
17
+ - Python version and OS
18
+ - Code samples or test cases if possible
19
+
20
+ ### Suggesting Enhancements
21
+
22
+ Enhancement suggestions are welcome! Please create an issue with:
23
+ - A clear description of the enhancement
24
+ - Use cases and examples
25
+ - Potential implementation approach (optional)
26
+
27
+ ### Pull Requests
28
+
29
+ 1. **Fork the repository** and create a new branch from `main`
30
+ 2. **Set up the development environment**:
31
+ ```bash
32
+ git clone https://github.com/YOUR_USERNAME/contexlog.git
33
+ cd contexlog
34
+ python -m venv .venv
35
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
36
+ pip install -e ".[dev]"
37
+ ```
38
+
39
+ 3. **Make your changes**:
40
+ - Write clear, readable code
41
+ - Add tests for new functionality
42
+ - Update documentation as needed
43
+ - Follow the existing code style
44
+
45
+ 4. **Run tests and checks**:
46
+ ```bash
47
+ # Run tests with coverage
48
+ pytest
49
+
50
+ # Format code with Black
51
+ black src tests examples
52
+
53
+ # Lint with Ruff
54
+ ruff check src tests examples
55
+
56
+ # Type check (optional)
57
+ mypy src
58
+ ```
59
+
60
+ 5. **Ensure all tests pass** and coverage remains >90%
61
+
62
+ 6. **Commit your changes**:
63
+ - Use clear, descriptive commit messages
64
+ - Reference related issues (e.g., "Fix #123: ...")
65
+
66
+ 7. **Push to your fork** and submit a pull request
67
+
68
+ 8. **Respond to review feedback** - we'll review your PR and may suggest changes
69
+
70
+ ## Development Guidelines
71
+
72
+ ### Code Style
73
+
74
+ - **Python version**: 3.11+
75
+ - **Line length**: 100 characters (Black default)
76
+ - **Formatting**: Use Black for code formatting
77
+ - **Linting**: Code must pass Ruff checks
78
+ - **Type hints**: Add type hints to all public APIs
79
+
80
+ ### Testing
81
+
82
+ - Write tests for all new functionality
83
+ - Maintain test coverage >90%
84
+ - Use pytest for testing
85
+ - Test both sync and async code paths
86
+ - Test error conditions and edge cases
87
+
88
+ ### Documentation
89
+
90
+ - Update README.md for user-facing changes
91
+ - Add docstrings (Google style) to all public functions and classes
92
+ - Update API documentation in `docs/` if needed
93
+ - Add examples for new features
94
+
95
+ ### Commit Messages
96
+
97
+ Use clear, descriptive commit messages:
98
+
99
+ ```
100
+ Add support for custom formatters
101
+
102
+ - Implement CustomFormatter class
103
+ - Add tests for custom formatter
104
+ - Update documentation with examples
105
+
106
+ Fixes #123
107
+ ```
108
+
109
+ ## Project Structure
110
+
111
+ ```
112
+ contexlog/
113
+ ├── src/contexlog/ # Source code
114
+ │ ├── __init__.py # Package exports
115
+ │ ├── core.py # Main implementation
116
+ │ └── py.typed # Type hint marker
117
+ ├── tests/ # Test suite
118
+ ├── docs/ # Documentation
119
+ ├── examples/ # Usage examples
120
+ └── .github/workflows/ # CI/CD workflows
121
+ ```
122
+
123
+ ## Release Process
124
+
125
+ (For maintainers)
126
+
127
+ 1. Update version in `pyproject.toml` and `src/contexlog/__init__.py`
128
+ 2. Update `CHANGELOG.md`
129
+ 3. Create a git tag: `git tag v0.x.0`
130
+ 4. Push tag: `git push origin v0.x.0`
131
+ 5. GitHub Actions will automatically build and publish to PyPI
132
+
133
+ ## Questions?
134
+
135
+ Feel free to open an issue for questions or join discussions in GitHub Discussions (if enabled).
136
+
137
+ ## License
138
+
139
+ By contributing to contexlog, you agree that your contributions will be licensed under the Apache License 2.0.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aprova GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ # Include documentation and license files
2
+ include LICENSE
3
+ include README.md
4
+ include CHANGELOG.md
5
+ include CONTRIBUTING.md
6
+ include CODE_OF_CONDUCT.md
7
+ include SECURITY.md
8
+
9
+ # Include package marker for type hints
10
+ include src/contexlog/py.typed
11
+
12
+ # Include tests
13
+ recursive-include tests *.py
14
+
15
+ # Include examples
16
+ recursive-include examples *.py
17
+
18
+ # Exclude build artifacts and CI files
19
+ exclude .gitignore
20
+ exclude .editorconfig
21
+ exclude .readthedocs.yaml
22
+ recursive-exclude .github *
23
+ recursive-exclude docs *
24
+ recursive-exclude * __pycache__
25
+ recursive-exclude * *.py[co]
26
+ recursive-exclude * .DS_Store