Metadata-Version: 2.4
Name: prettylogx
Version: 0.1.3
Summary: Beautiful, production-ready Python logging with colors and JSON output
Author-email: Rupesh Shinde <shinderupesh7896@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/RupeshShinde1307/prettylogx
Project-URL: Repository, https://github.com/RupeshShinde1307/prettylogx
Project-URL: Issues, https://github.com/RupeshShinde1307/prettylogx/issues
Keywords: logging,colorlog,json,structured-logging,pretty
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Logging
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Dynamic: license-file

# prettylogx

> Beautiful, production-ready Python logging — zero external dependencies.

[![PyPI version](https://img.shields.io/pypi/v/prettylogx.svg)](https://pypi.org/project/prettylogx/)
[![Python](https://img.shields.io/pypi/pyversions/prettylogx.svg)](https://pypi.org/project/prettylogx/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Make your Python logs beautiful and readable in 3 lines of code.  
No config files. No heavy dependencies. Just install and go.

---

## Install

```bash
pip install prettylogx
```

---

## Use

```python
from prettylogx import setup_logger

logger = setup_logger("my-app")

logger.info("Server started")
logger.warning("Database is slow")
logger.error("Payment failed")
```

**That's it.** Your logs now look like this:

```
12:30:45  INFO      my-app            Server started
12:30:45  WARNING   my-app            Database is slow
12:30:45  ERROR     my-app            Payment failed
```

Each level prints in its own color — green, yellow, red, magenta.

---

## More Examples

### Switch to JSON logs (for production)

```python
logger = setup_logger("my-app", json_logs=True)

logger.info("Server started")
```

```json
{"timestamp": "2024-01-15T10:30:45Z", "level": "INFO", "logger": "my-app", "message": "Server started", "module": "app", "function": "main", "line": 5}
```

---

### Show DEBUG level logs

```python
logger = setup_logger("my-app", level="DEBUG")

logger.debug("Connecting to DB...")
logger.info("Connected")
```

---

### Trace a request ID across all log lines

```python
from prettylogx import setup_logger, set_request_id, clear_request_id

logger = setup_logger("api")

set_request_id("req-abc123")

logger.info("Validating input")    # → [req-abc123] Validating input
logger.info("Querying database")   # → [req-abc123] Querying database
logger.info("Returning 200 OK")    # → [req-abc123] Returning 200 OK

clear_request_id()
```

---

### Log exceptions with full traceback

```python
try:
    result = 1 / 0
except ZeroDivisionError:
    logger.exception("Something went wrong")
```

```
12:30:45  ERROR     my-app            Something went wrong
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Traceback (most recent call last):
      File "app.py", line 3, in <module>
        result = 1 / 0
    ZeroDivisionError: division by zero
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
```

---

### Custom log levels

```python
logger.verbose("Very detailed info")         # below DEBUG
logger.success("Order processed!")           # between INFO and WARNING
```

---

## All Options

```python
setup_logger(
    name="my-app",       # name shown in every log line
    level="INFO",        # DEBUG / INFO / WARNING / ERROR / CRITICAL
    json_logs=False,     # True = JSON output for production
    show_time=True,      # show timestamp
    show_file=False,     # show filename and line number
    use_colors=True,     # False = plain text, no ANSI codes
)
```

---

## Before vs After

**Without prettylogx** — raw Python logging:

![Without prettylogx](https://raw.githubusercontent.com/RupeshShinde1307/prettylogx/main/docs/without.png)

No colors. No alignment. Hard to scan. Every line looks the same.

---

**With prettylogx** — beautiful, readable logs:

![With prettylogx](https://raw.githubusercontent.com/RupeshShinde1307/prettylogx/main/docs/with.png)

Colors per level. Fixed columns. Request ID tracing. Clean exception blocks.

---

## Why prettylogx?

| | Raw `logging` | prettylogx |
|---|:---:|:---:|
| Colored output | No | Yes |
| JSON logs | No | Yes |
| Request ID tracing | Manual | Built-in |
| Clean exceptions | No | Yes |
| One-line setup | No | Yes |
| Zero dependencies | Yes | Yes |

---

## Roadmap

- [ ] File handler — write to rotating log files
- [ ] Async support via `contextvars`
- [ ] Middleware for FastAPI / Flask / Django

---

## License

MIT — free to use in personal and commercial projects.

Made by [Rupesh Shinde](https://github.com/RupeshShinde1307)
