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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
contents: read
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Set up uv
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.0
rev: v0.16.4
hooks:
- id: ruff
- id: ruff-check
- id: ruff-format
16 changes: 8 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Repository Guidelines

## Project Structure & Module Organization
The reusable library code lives in `src/logurich/`, with `core.py` handling stdlib logging integration and queue setup, `console.py` encapsulating Rich rendering helpers, and `handler.py` providing custom Rich and console handlers. Shared state lives in `struct.py`. Tests reside in `tests/` and mirror module names (`test_core.py`, `test_rich.py`, `test_mp.py`). Runnable walkthroughs live in `examples/` for quick validation of logging scenarios. Packaging metadata is in `pyproject.toml` alongside the dependency lockfile `uv.lock`.
The reusable library code lives in `src/logurich/`, with `core.py` handling stdlib logging integration, the `LogurichLogger` adapter and queue setup, `console.py` encapsulating Rich console helpers, `handler.py` providing custom Rich and console handlers, `context.py` holding bound and ambient context, `serialize.py` converting Rich renderables to structured JSON, `premarkup.py` implementing the premarkup tags, `user_input.py` offering prompt helpers, and `opt_click.py` exposing the optional Click decorator. Shared state lives in `struct.py`. Tests reside in `tests/` and mirror module names (`test_core.py`, `test_rich.py`, `test_mp.py`). Runnable walkthroughs live in `examples/` for quick validation of logging scenarios. Packaging metadata is in `pyproject.toml` alongside the dependency lockfile `uv.lock`.

## Environment Setup
Use uv to keep the development environment reproducible. From the repo root run:
- `uv venv` to create `.venv`
- `source .venv/bin/activate`
- `uv pip install -e ".[dev]"` to install runtime and pytest extras
Re-run the last command whenever dependencies change.
- `uv sync --all-extras --all-groups` to create `.venv` and install runtime, optional and dev dependencies
- `source .venv/bin/activate` if you prefer an activated shell over `uv run`
Re-run the sync command whenever dependencies change. `dev` is a dependency group, not an extra, so `uv pip install -e ".[dev]"` does not work.

## Build, Test, and Development Commands
- `uv run pytest` executes the entire test suite with the active virtualenv.
- `uv run ruff check .` and `uv run ruff format --check .` mirror the lint gate.
- `uv run python examples/base.py` demonstrates the default logger output; adapt the script when validating new features.
- `uv run python examples/mp_example.py` stress-tests multi-process logging behaviour.
Publishing is orchestrated through the GitHub Actions workflows (`.github/workflows/`); manual builds use `python -m build` if you need a local wheel.
Publishing is orchestrated through the GitHub Actions workflows (`.github/workflows/`); pushing a `v*.*.*` tag builds and publishes to PyPI. Use `uv build` if you need a local wheel.

## Coding Style & Naming Conventions
Follow PEP 8 with four-space indentation and `snake_case` for functions, module-level helpers, and test names. Classes such as `Formatter` stay in `PascalCase`. Prefer explicit imports from `logurich`'s public API via `__init__.py`, and include type hints for new parameters and return values. Use `ctx(...)` inside `extra={"context": ...}` payloads for styled contextual values. Keep log message strings formatted via stdlib logging style (e.g., `logger.info("Value %s", value)`).
Follow PEP 8 with four-space indentation and `snake_case` for functions, module-level helpers, and test names. Classes such as `Formatter` stay in `PascalCase`. Prefer explicit imports from `logurich`'s public API via `__init__.py`, and include type hints for new parameters and return values. Pass context as plain call keywords (`logger.info("Login", user=ctx("alice"))`) and use `ctx(...)` for styled values; the 0.9 `extra={"context": ...}` and `extra={"renderables": ...}` payloads were removed and now raise. Keep log message strings formatted via stdlib logging style (e.g., `logger.info("Value %s", value)`).

## Testing Guidelines
Write tests with pytest and place them under `tests/`, naming files `test_<module>.py` and functions `test_<behaviour>`. Reuse shared fixtures from `tests/conftest.py`. Ensure new log formatting paths have representative assertions, and extend the example scripts when manual verification is useful. Run `uv run pytest` before opening a PR; aim to cover both the standard and rich rendering paths.

## Commit & Pull Request Guidelines
Commits follow Conventional Commit syntax (`type(scope): summary`) as seen in `git log`. Keep changes scoped and mention relevant modules in the scope. Pull requests must include a short summary, linked issues if applicable, and notes on testing (`uv run pytest`). Attach before/after screenshots or logs when changing console output. CI runs the test matrix across Python 3.9–3.13; wait for green builds before merging.
Commits follow Conventional Commit syntax (`type(scope): summary`) as seen in `git log`. Keep changes scoped and mention relevant modules in the scope. Pull requests must include a short summary, linked issues if applicable, and notes on testing (`uv run pytest`). Attach before/after screenshots or logs when changing console output. CI runs the test matrix across Python 3.9–3.14; wait for green builds before merging.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ logger = get_logger(__name__)

logger.info("Processed %s items", 12, batch="b-42")

request_logger = logger.bind(
request_id=logger.ctx("req-42", style="cyan")
)
request_logger = logger.bind(request_id=logger.ctx("req-42", style="cyan"))
request_logger.info("Request completed", duration_ms=17)

with logger.contextualize(user_id="alice"):
Expand Down Expand Up @@ -95,8 +93,8 @@ Console and file formats are independent:
```python
init_logger(
"INFO",
console="rich", # auto | rich | plain | json
file="json", # text | json
console="rich", # auto | rich | plain | json
file="json", # text | json
log_filename="app.log",
)
```
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
"rich>=13.7.0"
]
classifiers = [
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Logging",
Expand All @@ -32,6 +32,8 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Typing :: Typed",
"Operating System :: OS Independent",
]

Expand Down