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
6 changes: 0 additions & 6 deletions .github/workflows/auto-pr-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,15 @@ jobs:
const now = new Date().toISOString().slice(0,16).replace('T',' ');
const body = process.env.PR_BODY;
const base = context.payload.pull_request.base.ref;
const head = context.payload.pull_request.head.ref;
const update = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
body,
};

// Branch roles come from `.releaserc.cjs`:
// - base `release`: stable releases
// - base `main`: prereleases ("rc")
if (base === 'release') {
update.title = `Release! PR for ${now}`;
} else if (base === 'main') {
update.title = `PR for ${now}`;
}

await github.rest.pulls.update(update);
4 changes: 0 additions & 4 deletions .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,3 @@ jobs:
run: make all
env:
UV_PYTHON: ${{ matrix.python-version }}

- name: Check if code was reformatted
if: always()
run: git diff --exit-code
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.0.1-rc.1](https://github.com/disafronov/python-logging-objects-with-schema/compare/v1.0.0...v1.0.1-rc.1) (2026-05-22)

### Bug Fixes

* respect logger filters for validation errors ([d34e5b6](https://github.com/disafronov/python-logging-objects-with-schema/commit/d34e5b63f7326febee051a540dee197d9e02ff44))

## [1.0.0](https://github.com/disafronov/python-logging-objects-with-schema/compare/v0.4.1...v1.0.0) (2026-05-05)

### ⚠ BREAKING CHANGES
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PYTEST_CMD = uv run python -m pytest -v
COVERAGE_OPTS = --cov --cov-report=term-missing --cov-report=html

# Phony targets
.PHONY: all clean dead-code format help install lint test test-coverage
.PHONY: all clean dead-code format help install lint test

# Default target
help: ## Show this help message
Expand All @@ -30,7 +30,7 @@ format: ## Format code

lint: ## Run linting tools
@echo "Running linting tools..."
uv run black --check . && uv run isort --check-only . && uv run flake8 . && uv run mypy . && uv run bandit -r -c pyproject.toml .
uv run black --check . && uv run isort --check-only . && uv run flake8 . && uv run mypy && uv run bandit -c pyproject.toml -r src/

dead-code: ## Check for dead code using vulture
@echo "Checking for dead code..."
Expand Down
40 changes: 5 additions & 35 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "uv_build"

[project]
name = "logging-objects-with-schema"
version = "1.0.0"
version = "1.0.1rc1"
description = "Proxy logging wrapper that validates extra fields against a JSON schema."
readme = "README.md"
requires-python = ">=3.11"
Expand Down Expand Up @@ -54,47 +54,21 @@ dev = [

[tool.isort]
profile = "black"
line_length = 88
multi_line_output = 3

[tool.black]
line-length = 88
include = "\\.pyi?$"
extend-exclude = """
/(
\\.eggs
| \\.git
| \\.hg
| \\.mypy_cache
| \\.tox
| \\.venv
| build
| dist
)/
"""

[tool.flake8]
max-line-length = 88
extend-ignore = [ "E203", "W503" ]
exclude = [ ".venv", "__pycache__", ".git", "htmlcov" ]
exclude = [ ".venv" ]

[tool.mypy]
exclude = "tests/"
warn_return_any = true
files = [ "src" ]
strict = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true

[tool.bandit]
exclude_dirs = [ ".venv", "__pycache__", ".git", "htmlcov", "tests" ]

[tool.coverage.run]
source = [ "src" ]
Expand All @@ -103,11 +77,8 @@ branch = true
[tool.coverage.report]
fail_under = 100
exclude_lines = [
"def __repr__",
"if self\\.debug",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"@(abc\\.)?abstractmethod"
]
Expand All @@ -119,6 +90,5 @@ directory = "htmlcov"

[tool.vulture]
min_confidence = 80
exclude = [ "__pycache__" ]
ignore_names = [ "cls" ]
paths = [ "src", "tests" ]
paths = [ "src" ]
3 changes: 1 addition & 2 deletions src/logging_objects_with_schema/schema_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def _log(
sinfo, # sinfo - stack info from caller
)
try:
self.callHandlers(error_record)
self.handle(error_record)
except Exception:
# If handler failed, log error to stderr (standard logging behavior)
sys.stderr.write(f"Error in logging handler: {error_record}\n")
4 changes: 2 additions & 2 deletions tests/private/test_schema_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ def mock_dumps(*args, **kwargs):
assert "validation_errors" in output


def test_schema_logger_log_handles_callhandlers_exception(
def test_schema_logger_log_handles_validation_error_handler_exception(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""SchemaLogger._log should handle callHandlers exception gracefully."""
"""SchemaLogger._log should handle validation error handler exceptions."""
monkeypatch.chdir(tmp_path)
_write_schema(
tmp_path,
Expand Down
32 changes: 32 additions & 0 deletions tests/test_logging_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,35 @@ def test_schema_logger_accepts_extra_fields_without_error(

output = stream.getvalue()
assert "msg" in output


def test_schema_logger_validation_errors_respect_logger_filters(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Validation error records should pass through logger filters."""

monkeypatch.chdir(tmp_path)
_write_schema(
tmp_path,
{
"ServicePayload": {
"RequestID": {"type": "str", "source": "request_id"},
},
},
)

stream = StringIO()
handler = logging.StreamHandler(stream)
handler.setFormatter(logging.Formatter("%(levelname)s:%(message)s"))

logger = SchemaLogger("test-filtered-validation-errors")
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.addFilter(lambda record: not record.getMessage().startswith("{"))

logger.info("msg", extra={"request_id": 42})

output = stream.getvalue()
assert "INFO:msg" in output
assert "validation_errors" not in output
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading