Metadata-Version: 2.4
Name: small-logger
Version: 0.1.0
Summary: A tiny Loguru wrapper for styled logging
Author: Seppe Van Bogaert
License: MIT License
        
        Copyright (c) 2026 Seppe Van Bogaert
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: loguru>=0.7.0
Requires-Dist: platformdirs>=3.0
Dynamic: license-file

# small-logger

A tiny, opinionated [Loguru](https://github.com/Delgan/loguru) wrapper that gives your Python apps a consistent, readable log format in two lines of code.

```
2026-05-11 14:32:01 | INFO     | myapp:main:42                             | Server started on port 8080
2026-05-11 14:32:01 | ERROR    | myapp:handle_request:87                   | Connection refused
                                                                            | Traceback shown below
```

## Installation

```
uv add small-logger
```

```
pip install small-logger
```

## Quick start

```python
from small_logger import init_logger, get_logger

init_logger()  # call once at the start of your app

logger = get_logger()
logger.info("Server started")
logger.warning("Disk usage above 80%")
```

## File logging

Pass your app's name to enable automatic file logging:

```python
init_logger(app_name="my-app")
```

Logs are written to the platform-appropriate directory:

| Platform | Path |
|----------|------|
| Windows  | `%LOCALAPPDATA%\my-app\Logs\app.log` |
| macOS    | `~/Library/Logs/my-app/app.log` |
| Linux    | `~/.local/state/my-app/log/app.log` |

Files rotate daily at midnight, are kept for 7 days, and are compressed to `.zip` on rotation.

## API

### `init_logger`

```python
init_logger(
    level="INFO",       # TRACE | DEBUG | INFO | SUCCESS | WARNING | ERROR | CRITICAL
    app_name=None,      # enables file logging when provided
    file=None,          # override file logging on/off explicitly
)
```

| Parameter | Default | Description |
|-----------|---------|-------------|
| `level` | `"INFO"` | Minimum level to log. |
| `app_name` | `None` | App name for the log file path. When set, file logging is enabled by default. |
| `file` | `None` | Explicitly enable (`True`) or disable (`False`) file logging, regardless of `app_name`. |

Call this **once** at startup. Subsequent calls are no-ops.

### `get_logger`

```python
logger = get_logger()
logger = get_logger(request_id="abc123", user_id=42)
```

Returns a Loguru logger bound with optional key-value context. The context is included in every message emitted through that logger instance.

## Multiline messages

Continuation lines are automatically indented to align with the first line:

```python
logger.info("Query returned 3 rows:\nrow1\nrow2\nrow3")
```

```
2026-05-11 14:32:01 | INFO     | myapp:run:10                              | Query returned 3 rows:
                                                                            | row1
                                                                            | row2
                                                                            | row3
```

## License

MIT
