Metadata-Version: 2.2
Name: grrr
Version: 0.7.1
Summary: A set of common tools for various bear projects.
Author-Email: chaz <bright.lid5647@fastmail.com>
Requires-Python: >=3.15
Requires-Dist: fond>=0.3.19
Requires-Dist: orjson>=3.11.9
Requires-Dist: rich>=14.1.0
Description-Content-Type: text/markdown

# grrr

[![PyPI version](https://img.shields.io/pypi/v/grrr.svg)](https://pypi.org/project/grrr/)

Fast, colorful logging and a small collection of practical tools for modern Python.

`grrr` combines a [Fond](https://pypi.org/project/fond/)-backed native logger with lightweight shell-command helpers
and JSON settings. It requires CPython 3.15 or newer.

## Installation

```bash
uv pip install grrr
```

## Logging

```python
from grrr import Logger, LogLevel

with Logger("app", level=LogLevel.DEBUG, console="split") as log:
    log.debug("starting")
    log.info("ready")
    log.warning("check the configuration")
```

Console output supports color and can be routed to stdout, stderr, or split by
severity. File, buffer, and queued loggers use the same API:

```python
from grrr import Logger

with Logger.file_logger("logs/app.log") as log:
    log.info("written to a rotating file")

with Logger.buffer_logger() as log:
    log.success("captured in memory")
    record = log.records()[0]
    print(record.level, record.message, record.timestamp)

with Logger.queue_logger(console="split") as log:
    log.info("handled by the native listener")
    log.flush()
```

Child loggers share their parent's sinks while adding a qualified name:

```python
with Logger("service") as log:
    database = log.child("database")
    database.info("connected")
```

Exception tracking is opt-in and stores text snapshots rather than live frames:

```python
with Logger("worker", track_exceptions=True) as log:
    try:
        raise RuntimeError("something growled")
    except RuntimeError:
        log.exception("job failed")

    print(log.exceptions)
```

## Shell commands

Command factories preserve argument boundaries and execute without an implicit
shell by default:

```python
import sys

from grrr.cli import BaseShellCommand

command = BaseShellCommand.adhoc(sys.executable, "-c", "print('hello')")
print(command.get())
```

Synchronous and asynchronous shell sessions are available when explicit shell
interpretation or streaming output is needed.

## JSON settings

```python
from grrr.config import SimpleSettingsManager

with SimpleSettingsManager("my-app") as settings:
    settings.set("theme", "dark")
    print(settings.get("theme"))
```

Settings are stored in one JSON file, with access serialized by a file lock and
resources released through the context-managed API.

## Version

```bash
python -c "import grrr; print(grrr.__version__)"
```
