structguru 0.1.0__tar.gz → 0.2.0__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.
- structguru-0.2.0/.github/workflows/ci.yml +31 -0
- structguru-0.2.0/.gitignore +53 -0
- structguru-0.2.0/.jetaprog/runConfigurations.json +44 -0
- structguru-0.2.0/Makefile +40 -0
- {structguru-0.1.0 → structguru-0.2.0}/PKG-INFO +20 -6
- {structguru-0.1.0 → structguru-0.2.0}/README.md +13 -5
- structguru-0.2.0/docs/api/config.md +3 -0
- structguru-0.2.0/docs/api/core.md +3 -0
- structguru-0.2.0/docs/api/exceptions.md +3 -0
- structguru-0.2.0/docs/api/index.md +12 -0
- structguru-0.2.0/docs/api/integrations/asgi.md +3 -0
- structguru-0.2.0/docs/api/integrations/celery.md +3 -0
- structguru-0.2.0/docs/api/integrations/django.md +3 -0
- structguru-0.2.0/docs/api/integrations/flask.md +3 -0
- structguru-0.2.0/docs/api/integrations/grpc.md +3 -0
- structguru-0.2.0/docs/api/integrations/httpx.md +3 -0
- structguru-0.2.0/docs/api/integrations/requests.md +3 -0
- structguru-0.2.0/docs/api/integrations/sentry.md +3 -0
- structguru-0.2.0/docs/api/integrations/sqlalchemy.md +3 -0
- structguru-0.2.0/docs/api/integrations/stdlib.md +3 -0
- structguru-0.2.0/docs/api/metrics.md +3 -0
- structguru-0.2.0/docs/api/otel.md +3 -0
- structguru-0.2.0/docs/api/processors.md +3 -0
- structguru-0.2.0/docs/api/queued.md +3 -0
- structguru-0.2.0/docs/api/redaction.md +3 -0
- structguru-0.2.0/docs/api/routing.md +3 -0
- structguru-0.2.0/docs/api/sampling.md +3 -0
- structguru-0.2.0/docs/index.md +349 -0
- structguru-0.2.0/docs/integrations.md +268 -0
- structguru-0.2.0/examples/full_stack_fastapi/main.py +78 -0
- structguru-0.2.0/mkdocs.yml +59 -0
- {structguru-0.1.0 → structguru-0.2.0}/pyproject.toml +30 -4
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/__init__.py +7 -1
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/config.py +31 -12
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/core.py +117 -24
- structguru-0.2.0/src/structguru/exceptions.py +134 -0
- structguru-0.2.0/src/structguru/integrations/_util.py +21 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/integrations/asgi.py +39 -13
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/integrations/celery.py +6 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/integrations/django.py +24 -21
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/integrations/flask.py +9 -5
- structguru-0.2.0/src/structguru/integrations/grpc.py +143 -0
- structguru-0.2.0/src/structguru/integrations/httpx.py +65 -0
- structguru-0.2.0/src/structguru/integrations/requests.py +69 -0
- structguru-0.2.0/src/structguru/integrations/sentry.py +142 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/integrations/sqlalchemy.py +23 -5
- structguru-0.2.0/src/structguru/integrations/stdlib.py +87 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/metrics.py +5 -2
- structguru-0.2.0/src/structguru/queued.py +131 -0
- structguru-0.2.0/src/structguru/redaction.py +116 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/sampling.py +33 -2
- structguru-0.2.0/tests/benchmarks/benchmark_queue_memory.py +37 -0
- structguru-0.2.0/tests/benchmarks/test_bench_core.py +149 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/conftest.py +3 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_config.py +79 -1
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_core.py +128 -18
- structguru-0.2.0/tests/test_exceptions.py +230 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_integrations/test_asgi.py +61 -0
- structguru-0.2.0/tests/test_integrations/test_flask.py +140 -0
- structguru-0.2.0/tests/test_integrations/test_grpc.py +305 -0
- structguru-0.2.0/tests/test_integrations/test_httpx.py +59 -0
- structguru-0.2.0/tests/test_integrations/test_requests.py +74 -0
- structguru-0.2.0/tests/test_integrations/test_sentry.py +151 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_integrations/test_sqlalchemy.py +65 -0
- structguru-0.2.0/tests/test_integrations/test_stdlib.py +79 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_metrics.py +10 -0
- structguru-0.2.0/tests/test_queued.py +119 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_redaction.py +42 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_sampling.py +35 -0
- {structguru-0.1.0 → structguru-0.2.0}/uv.lock +773 -4
- structguru-0.1.0/.agents/SCHEMA.yaml +0 -1080
- structguru-0.1.0/.agents/STANDARDS.md +0 -1170
- structguru-0.1.0/.agents/STANDARD_UPDATE_PLAYBOOK.md +0 -175
- structguru-0.1.0/.agents/contexts/conventions/FILE_PLACEMENT_MAP.md +0 -99
- structguru-0.1.0/.agents/contexts/conventions/STYLE_PROFILE.md +0 -128
- structguru-0.1.0/.agents/contexts/security/DEPENDENCY_POLICY.md +0 -53
- structguru-0.1.0/.agents/contexts/security/SECRETS_POLICY.md +0 -55
- structguru-0.1.0/.agents/contexts/security/SECURITY_OVERVIEW.md +0 -67
- structguru-0.1.0/.agents/contexts/security/THREAT_MODEL.md +0 -59
- structguru-0.1.0/.agents/rag.manifest.template.yaml +0 -34
- structguru-0.1.0/.agents/rag.manifest.yaml +0 -34
- structguru-0.1.0/.agents/research/agent-runtime-features_codex-claude-gemini_v0.1.0.md +0 -118
- structguru-0.1.0/.agents/research/agentic-cybersecurity-best-practices_v0.1.0.md +0 -157
- structguru-0.1.0/.agents/research/token-compression-techniques_v0.1.0.md +0 -322
- structguru-0.1.0/.agents/runbooks/BOOTSTRAP_EMPTY_REPO.md +0 -154
- structguru-0.1.0/.agents/runbooks/MIGRATE_FROM_CURSOR.md +0 -119
- structguru-0.1.0/.agents/runbooks/README.md +0 -35
- structguru-0.1.0/.agents/runbooks/security/SECURITY_CHANGE_CHECKLIST.md +0 -73
- structguru-0.1.0/.agents/runbooks/update_project_conventions_from_git.md +0 -102
- structguru-0.1.0/.agents/schemas/README.md +0 -31
- structguru-0.1.0/.agents/skills/project-conventions/SKILL.md +0 -76
- structguru-0.1.0/.agents/skills/senior-python-developer/SKILL.md +0 -97
- structguru-0.1.0/.agents/templates/AGENTS_TEMPLATE.md +0 -62
- structguru-0.1.0/.agents/templates/CURSORIGNORE_TEMPLATE +0 -15
- structguru-0.1.0/.agents/templates/CURSORINDEXINGIGNORE_TEMPLATE +0 -9
- structguru-0.1.0/.agents/templates/CURSOR_GLOBAL_RULE_TEMPLATE.mdc +0 -23
- structguru-0.1.0/.agents/templates/DOCUMENT_TEMPLATE.md +0 -90
- structguru-0.1.0/.agents/templates/FILE_PLACEMENT_MAP_TEMPLATE.md +0 -83
- structguru-0.1.0/.agents/templates/RESEARCH_TEMPLATE.md +0 -112
- structguru-0.1.0/.agents/templates/RUNBOOK_TEMPLATE.md +0 -44
- structguru-0.1.0/.agents/templates/SECURITY_POLICY_TEMPLATE.md +0 -53
- structguru-0.1.0/.agents/templates/SKILL_TEMPLATE.md +0 -76
- structguru-0.1.0/.agents/templates/SOURCE_TEMPLATE.md +0 -63
- structguru-0.1.0/.agents/templates/STYLE_PROFILE_TEMPLATE.md +0 -112
- structguru-0.1.0/.aiexclude +0 -43
- structguru-0.1.0/.claude/settings.local.json +0 -29
- structguru-0.1.0/.idea/.gitignore +0 -10
- structguru-0.1.0/.idea/copilot.data.migration.ask2agent.xml +0 -6
- structguru-0.1.0/.idea/inspectionProfiles/Project_Default.xml +0 -14
- structguru-0.1.0/.idea/inspectionProfiles/profiles_settings.xml +0 -6
- structguru-0.1.0/.idea/misc.xml +0 -8
- structguru-0.1.0/.idea/modules.xml +0 -8
- structguru-0.1.0/.idea/structguru.iml +0 -10
- structguru-0.1.0/.idea/vcs.xml +0 -6
- structguru-0.1.0/.idea/workspace.xml +0 -128
- structguru-0.1.0/AGENT.md +0 -1
- structguru-0.1.0/AGENTS.md +0 -67
- structguru-0.1.0/CLAUDE.md +0 -1
- structguru-0.1.0/CODE_SUMMARY.md +0 -52
- structguru-0.1.0/GEMINI.md +0 -1
- structguru-0.1.0/Makefile +0 -35
- structguru-0.1.0/PROMPT_STRUCTGURU.md +0 -701
- structguru-0.1.0/src/structguru/exceptions.py +0 -82
- structguru-0.1.0/src/structguru/integrations/grpc.py +0 -60
- structguru-0.1.0/src/structguru/integrations/sentry.py +0 -97
- structguru-0.1.0/src/structguru/queued.py +0 -88
- structguru-0.1.0/src/structguru/redaction.py +0 -75
- structguru-0.1.0/tests/test_exceptions.py +0 -99
- structguru-0.1.0/tests/test_integrations/test_flask.py +0 -73
- structguru-0.1.0/tests/test_integrations/test_grpc.py +0 -60
- structguru-0.1.0/tests/test_integrations/test_sentry.py +0 -83
- structguru-0.1.0/tests/test_queued.py +0 -63
- {structguru-0.1.0 → structguru-0.2.0}/LICENSE +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/integrations/__init__.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/otel.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/processors.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/py.typed +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/src/structguru/routing.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_integrations/__init__.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_integrations/test_celery.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_integrations/test_django.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_otel.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_processors.py +0 -0
- {structguru-0.1.0 → structguru-0.2.0}/tests/test_routing.py +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
with:
|
|
22
|
+
enable-cache: true
|
|
23
|
+
|
|
24
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
25
|
+
run: uv python install ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: make install
|
|
29
|
+
|
|
30
|
+
- name: Run quality gates
|
|
31
|
+
run: make check
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Byte-compiled / optimized
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
|
|
15
|
+
# IDE
|
|
16
|
+
.idea/
|
|
17
|
+
.vscode/
|
|
18
|
+
*.swp
|
|
19
|
+
|
|
20
|
+
# OS
|
|
21
|
+
.DS_Store
|
|
22
|
+
|
|
23
|
+
# Tool caches
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
|
|
28
|
+
# Coverage
|
|
29
|
+
.coverage
|
|
30
|
+
htmlcov/
|
|
31
|
+
|
|
32
|
+
# Logs
|
|
33
|
+
*.log
|
|
34
|
+
/.agents/
|
|
35
|
+
/AGENT.md
|
|
36
|
+
/AGENTS.md
|
|
37
|
+
/ARCHIVE_INDEX.md
|
|
38
|
+
/CLAUDE.md
|
|
39
|
+
/GEMINI.md
|
|
40
|
+
/PROMPT_STRUCTGURU.md
|
|
41
|
+
/.aiexclude
|
|
42
|
+
|
|
43
|
+
# MkDocs
|
|
44
|
+
/site/
|
|
45
|
+
|
|
46
|
+
# Tooling caches & local scratch
|
|
47
|
+
/.claude/
|
|
48
|
+
/.uv-cache/
|
|
49
|
+
|
|
50
|
+
# Unpacked standards archives & scratch / report files (not source)
|
|
51
|
+
/ai-agents-standards-*/
|
|
52
|
+
/errors.json
|
|
53
|
+
/test_perf.py
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"id": "146f2f42-492f-73de-f05e-28bf6bf5a3f3",
|
|
6
|
+
"name": "structguru Run",
|
|
7
|
+
"type": "uv",
|
|
8
|
+
"isTemporary": false,
|
|
9
|
+
"settings": {
|
|
10
|
+
"type": "uv",
|
|
11
|
+
"command": "run",
|
|
12
|
+
"arguments": [],
|
|
13
|
+
"environment": {},
|
|
14
|
+
"workingDirectory": "/Users/apavlov/Projects/structguru"
|
|
15
|
+
},
|
|
16
|
+
"beforeLaunch": [],
|
|
17
|
+
"allowParallelRun": false,
|
|
18
|
+
"storeAsProjectFile": true,
|
|
19
|
+
"folderName": null
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "a7eba24c-3bf5-df16-8a48-0d6fd443ee84",
|
|
23
|
+
"name": "structguru Sync",
|
|
24
|
+
"type": "uv",
|
|
25
|
+
"isTemporary": true,
|
|
26
|
+
"settings": {
|
|
27
|
+
"type": "uv",
|
|
28
|
+
"command": "sync",
|
|
29
|
+
"arguments": [],
|
|
30
|
+
"environment": {},
|
|
31
|
+
"workingDirectory": "/Users/apavlov/Projects/structguru"
|
|
32
|
+
},
|
|
33
|
+
"beforeLaunch": [],
|
|
34
|
+
"allowParallelRun": false,
|
|
35
|
+
"storeAsProjectFile": true,
|
|
36
|
+
"folderName": null
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"activeConfigurationId": "a7eba24c-3bf5-df16-8a48-0d6fd443ee84",
|
|
40
|
+
"recentConfigurationIds": [
|
|
41
|
+
"a7eba24c-3bf5-df16-8a48-0d6fd443ee84",
|
|
42
|
+
"146f2f42-492f-73de-f05e-28bf6bf5a3f3"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.DEFAULT_GOAL := help
|
|
2
|
+
|
|
3
|
+
.PHONY: help install test bench lint format typecheck check clean build publish-test publish
|
|
4
|
+
|
|
5
|
+
help: ## Show this help
|
|
6
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}'
|
|
7
|
+
|
|
8
|
+
install: ## Install dev dependencies and all integration extras
|
|
9
|
+
uv sync --all-extras
|
|
10
|
+
|
|
11
|
+
test: ## Run tests
|
|
12
|
+
uv run python -m pytest --ignore=tests/benchmarks
|
|
13
|
+
|
|
14
|
+
bench: ## Run benchmarks
|
|
15
|
+
uv run python -m pytest tests/benchmarks/ --benchmark-only
|
|
16
|
+
|
|
17
|
+
lint: ## Run linter and format check
|
|
18
|
+
uv run ruff check .
|
|
19
|
+
uv run ruff format --check .
|
|
20
|
+
|
|
21
|
+
format: ## Format code
|
|
22
|
+
uv run ruff format .
|
|
23
|
+
|
|
24
|
+
typecheck: ## Run type checker (mypy strict)
|
|
25
|
+
uv run python -m mypy src/
|
|
26
|
+
|
|
27
|
+
check: lint typecheck test ## Run lint + typecheck + tests
|
|
28
|
+
|
|
29
|
+
clean: ## Remove build artifacts and caches
|
|
30
|
+
rm -rf dist/ build/ src/*.egg-info .mypy_cache .pytest_cache .ruff_cache
|
|
31
|
+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
32
|
+
|
|
33
|
+
build: clean ## Build sdist and wheel
|
|
34
|
+
uv build
|
|
35
|
+
|
|
36
|
+
publish-test: build ## Publish to TestPyPI
|
|
37
|
+
uv publish --publish-url https://test.pypi.org/legacy/
|
|
38
|
+
|
|
39
|
+
publish: build ## Publish to PyPI
|
|
40
|
+
uv publish
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: structguru
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A loguru-style ergonomic API for structlog
|
|
5
5
|
Project-URL: Homepage, https://github.com/kidoz/structguru
|
|
6
6
|
Project-URL: Repository, https://github.com/kidoz/structguru
|
|
@@ -29,7 +29,9 @@ Requires-Dist: celery>=5.0; extra == 'all'
|
|
|
29
29
|
Requires-Dist: django>=4.0; extra == 'all'
|
|
30
30
|
Requires-Dist: flask>=2.0; extra == 'all'
|
|
31
31
|
Requires-Dist: grpcio>=1.50; extra == 'all'
|
|
32
|
+
Requires-Dist: httpx>=0.20; extra == 'all'
|
|
32
33
|
Requires-Dist: opentelemetry-api>=1.0; extra == 'all'
|
|
34
|
+
Requires-Dist: requests>=2.0; extra == 'all'
|
|
33
35
|
Requires-Dist: sentry-sdk>=1.0; extra == 'all'
|
|
34
36
|
Requires-Dist: sqlalchemy>=2.0; extra == 'all'
|
|
35
37
|
Provides-Extra: celery
|
|
@@ -40,8 +42,12 @@ Provides-Extra: flask
|
|
|
40
42
|
Requires-Dist: flask>=2.0; extra == 'flask'
|
|
41
43
|
Provides-Extra: grpc
|
|
42
44
|
Requires-Dist: grpcio>=1.50; extra == 'grpc'
|
|
45
|
+
Provides-Extra: httpx
|
|
46
|
+
Requires-Dist: httpx>=0.20; extra == 'httpx'
|
|
43
47
|
Provides-Extra: otel
|
|
44
48
|
Requires-Dist: opentelemetry-api>=1.0; extra == 'otel'
|
|
49
|
+
Provides-Extra: requests
|
|
50
|
+
Requires-Dist: requests>=2.0; extra == 'requests'
|
|
45
51
|
Provides-Extra: sentry
|
|
46
52
|
Requires-Dist: sentry-sdk>=1.0; extra == 'sentry'
|
|
47
53
|
Provides-Extra: sqlalchemy
|
|
@@ -133,12 +139,13 @@ logger.fatal("Alias for critical")
|
|
|
133
139
|
|
|
134
140
|
### Brace formatting
|
|
135
141
|
|
|
136
|
-
Arguments
|
|
142
|
+
Arguments used in `str.format` placeholders are consumed by formatting (matching loguru behaviour). Extra kwargs that are **not** in any placeholder are forwarded as structured fields:
|
|
137
143
|
|
|
138
144
|
```python
|
|
139
|
-
logger.info("User {user_id} logged in
|
|
140
|
-
# message: "User 42 logged in
|
|
141
|
-
#
|
|
145
|
+
logger.info("User {user_id} logged in", user_id=42, ip="10.0.0.1")
|
|
146
|
+
# message: "User 42 logged in"
|
|
147
|
+
# ip: "10.0.0.1" (extra kwarg kept as structured field)
|
|
148
|
+
# user_id is consumed by formatting and not duplicated
|
|
142
149
|
```
|
|
143
150
|
|
|
144
151
|
### Bound context
|
|
@@ -224,11 +231,12 @@ configure_structlog(service="myapp", json_logs=False)
|
|
|
224
231
|
Mask sensitive fields automatically:
|
|
225
232
|
|
|
226
233
|
```python
|
|
234
|
+
import re
|
|
227
235
|
from structguru import RedactingProcessor
|
|
228
236
|
|
|
229
237
|
redactor = RedactingProcessor(
|
|
230
238
|
sensitive_keys=frozenset({"password", "token", "ssn"}),
|
|
231
|
-
patterns=[r"\b\d{3}-\d{2}-\d{4}\b"], # SSN pattern
|
|
239
|
+
patterns=[re.compile(r"\b\d{3}-\d{2}-\d{4}\b")], # SSN pattern
|
|
232
240
|
replacement="***",
|
|
233
241
|
)
|
|
234
242
|
# Add to your structlog processor chain
|
|
@@ -377,11 +385,17 @@ sentry = SentryProcessor(event_level=logging.ERROR, tag_keys=frozenset({"service
|
|
|
377
385
|
- structlog >= 24.1.0
|
|
378
386
|
- orjson >= 3.9.0
|
|
379
387
|
|
|
388
|
+
## Documentation & Examples
|
|
389
|
+
|
|
390
|
+
- **[Integrations Guide](docs/integrations.md)** — Detailed instructions for setting up frameworks.
|
|
391
|
+
- **[Full-stack Example](examples/full_stack_fastapi/main.py)** — FastAPI + Celery + SQLAlchemy in action.
|
|
392
|
+
|
|
380
393
|
## Development
|
|
381
394
|
|
|
382
395
|
```bash
|
|
383
396
|
uv sync
|
|
384
397
|
uv run pytest
|
|
398
|
+
make bench
|
|
385
399
|
uv run ruff check .
|
|
386
400
|
uv run mypy src/
|
|
387
401
|
```
|
|
@@ -83,12 +83,13 @@ logger.fatal("Alias for critical")
|
|
|
83
83
|
|
|
84
84
|
### Brace formatting
|
|
85
85
|
|
|
86
|
-
Arguments
|
|
86
|
+
Arguments used in `str.format` placeholders are consumed by formatting (matching loguru behaviour). Extra kwargs that are **not** in any placeholder are forwarded as structured fields:
|
|
87
87
|
|
|
88
88
|
```python
|
|
89
|
-
logger.info("User {user_id} logged in
|
|
90
|
-
# message: "User 42 logged in
|
|
91
|
-
#
|
|
89
|
+
logger.info("User {user_id} logged in", user_id=42, ip="10.0.0.1")
|
|
90
|
+
# message: "User 42 logged in"
|
|
91
|
+
# ip: "10.0.0.1" (extra kwarg kept as structured field)
|
|
92
|
+
# user_id is consumed by formatting and not duplicated
|
|
92
93
|
```
|
|
93
94
|
|
|
94
95
|
### Bound context
|
|
@@ -174,11 +175,12 @@ configure_structlog(service="myapp", json_logs=False)
|
|
|
174
175
|
Mask sensitive fields automatically:
|
|
175
176
|
|
|
176
177
|
```python
|
|
178
|
+
import re
|
|
177
179
|
from structguru import RedactingProcessor
|
|
178
180
|
|
|
179
181
|
redactor = RedactingProcessor(
|
|
180
182
|
sensitive_keys=frozenset({"password", "token", "ssn"}),
|
|
181
|
-
patterns=[r"\b\d{3}-\d{2}-\d{4}\b"], # SSN pattern
|
|
183
|
+
patterns=[re.compile(r"\b\d{3}-\d{2}-\d{4}\b")], # SSN pattern
|
|
182
184
|
replacement="***",
|
|
183
185
|
)
|
|
184
186
|
# Add to your structlog processor chain
|
|
@@ -327,11 +329,17 @@ sentry = SentryProcessor(event_level=logging.ERROR, tag_keys=frozenset({"service
|
|
|
327
329
|
- structlog >= 24.1.0
|
|
328
330
|
- orjson >= 3.9.0
|
|
329
331
|
|
|
332
|
+
## Documentation & Examples
|
|
333
|
+
|
|
334
|
+
- **[Integrations Guide](docs/integrations.md)** — Detailed instructions for setting up frameworks.
|
|
335
|
+
- **[Full-stack Example](examples/full_stack_fastapi/main.py)** — FastAPI + Celery + SQLAlchemy in action.
|
|
336
|
+
|
|
330
337
|
## Development
|
|
331
338
|
|
|
332
339
|
```bash
|
|
333
340
|
uv sync
|
|
334
341
|
uv run pytest
|
|
342
|
+
make bench
|
|
335
343
|
uv run ruff check .
|
|
336
344
|
uv run mypy src/
|
|
337
345
|
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Welcome to the `structguru` API reference.
|
|
4
|
+
|
|
5
|
+
These pages are automatically generated from the source code docstrings using the `mkdocstrings` plugin. This ensures that the documentation is always up-to-date with the actual code implementation.
|
|
6
|
+
|
|
7
|
+
Navigate through the sub-sections to explore the modules:
|
|
8
|
+
|
|
9
|
+
* **Core**: The main Loguru-style facade and logger implementation.
|
|
10
|
+
* **Configuration**: How to set up and configure structlog.
|
|
11
|
+
* **Processors**: Built-in processors for standardizing and enriching logs.
|
|
12
|
+
* **Integrations**: Adapters for popular frameworks like ASGI, Celery, Django, Flask, etc.
|