Metadata-Version: 2.4
Name: az-smart-logger
Version: 1.0.5
Summary: Smart Logger library for Python projects with FastAPI, Flask, and Django support
Home-page: https://github.com/ShahabazAlam/smart-logger
Author: Shahabaz Alam
Author-email: Shahabaz Alam <shahabazalam1@gmail.com>
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: annotated-types==0.7.0
Requires-Dist: anyio==4.10.0
Requires-Dist: argon2-cffi==25.1.0
Requires-Dist: argon2-cffi-bindings==25.1.0
Requires-Dist: cffi==2.0.0
Requires-Dist: click==8.2.1
Requires-Dist: fastapi==0.116.1
Requires-Dist: h11==0.16.0
Requires-Dist: httptools==0.6.4
Requires-Dist: idna==3.10
Requires-Dist: Jinja2==3.1.6
Requires-Dist: markdown-it-py==4.0.0
Requires-Dist: MarkupSafe==3.0.2
Requires-Dist: mdurl==0.1.2
Requires-Dist: passlib==1.7.4
Requires-Dist: pycparser==2.23
Requires-Dist: pydantic==2.11.7
Requires-Dist: pydantic_core==2.33.2
Requires-Dist: Pygments==2.19.2
Requires-Dist: PyJWT==2.10.1
Requires-Dist: python-dotenv==1.1.1
Requires-Dist: PyYAML==6.0.2
Requires-Dist: rich==14.1.0
Requires-Dist: shellingham==1.5.4
Requires-Dist: sniffio==1.3.1
Requires-Dist: SQLAlchemy==2.0.43
Requires-Dist: typer==0.17.4
Requires-Dist: typing_extensions==4.15.0
Requires-Dist: typing-inspection==0.4.1
Requires-Dist: uvicorn[standard]>=0.23.0
Requires-Dist: uvloop==0.21.0
Requires-Dist: watchfiles==1.1.0
Requires-Dist: websockets==15.0.1
Requires-Dist: psutil==7.1.0
Requires-Dist: python-socketio[asyncio_server]==5.13.0
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# Smart Logger

**Smart Logger** is a **Python logging library** with **FastAPI, Flask, and Django** support.
It provides **UUID-based logs**, **date/parent_folder structured logs**, **database metadata storage**, and a **FastAPI dashboard** with filters, real-time monitoring, charts.

---

## Features

* **Multi-framework support:** FastAPI, Flask, Django
* **Structured logging:** UUID for each log entry
* **Dynamic folder structure:** `date/parent_folder/filename.log`
* **Database metadata storage** (default SQLite)
* **SmartLogger class with logging levels:**

  * `logger.info()`
  * `logger.error()`
  * `logger.warning()`
  * `logger.critical()`
  * `logger.debug()`
* **FastAPI Dashboard UI:**

  * Real-time logs
  * Filter logs by **date, time, UUID, log type**
  * Bar charts for **daily, monthly, yearly log insights**
  * System info cards and statistics
  * Interactive UI with logout functionality
* **Secure:** input sanitization, token-based authentication, blacklist token support
* **CLI commands** for user management, configuration, and server launch

---

## Installation

```bash
pip install az-smart-logger
```

---

## Quick Setup (Step by Step)

1. **Generate default config file**

   ```bash
   smart-logger make-smart-logger-default-conf
   ```

   → This creates a config file in your project folder.

2. **Update config file**

   * Add your **database credentials**, **log paths**, and other settings.

3. **Set the configuration**

   ```bash
   smart-logger set_config
   ```

4. **Verify active configuration**

   ```bash
   smart-logger show_config
   ```

   → Ensures everything is correctly set.

5. **Initialize database tables**

   ```bash
   smart-logger init-db
   ```

6. **Create an admin user**

   ```bash
   smart-logger create-admin-user
   ```

7. **Run the Smart Logger Dashboard UI**

   ```bash
   smart-logger ui --host 127.0.0.1 --port 8000
   ```

✅ Now your logging system with UI is ready!

---

## Usage

### 1. FastAPI Example

```python
from fastapi import FastAPI
from smart_logger import SmartLogger

app = FastAPI()
logger = SmartLogger()

@app.get("/")
def home():
    logger.info("Home accessed")  # UUID, folder, filename auto-detected
    return {"message": "Hello FastAPI"}
```

### 2. Flask Example

```python
from flask import Flask
from smart_logger import SmartLogger

app = Flask(__name__)
logger = SmartLogger()

@app.route("/")
def home():
    logger.info("Home accessed")
    return "Hello Flask"
```

### 3. Django Example

```python
from smart_logger import SmartLogger

logger = SmartLogger()

def example_view(request):
    logger.info("Django view accessed")
    from django.http import HttpResponse
    return HttpResponse("Hello Django")
```

---

## CLI Commands

### Launch Dashboard UI

```bash
smart-logger ui --host 127.0.0.1 --port 8000 --workers 1 --reload False
```

* `--reload` optional (default `False`)
* Runs **isolated FastAPI server** independent of main project

### Initialize Database Tables

```bash
smart-logger init-db
```

### Admin User Management

* **Create admin user:**

```bash
smart-logger create-admin-user
```

* **Change password:**

```bash
smart-logger change-password <email>
```

* **Forgot password (reset without old password):**

```bash
smart-logger forgot-password <email>
```

* **List users:**

```bash
smart-logger list-users
```

* **Delete user:**

```bash
smart-logger delete-user <email>
```

### Configuration Management

* **Set global config:**

```bash
smart-logger set_config
```

* **Show active config:**

```bash
smart-logger show_config
```

* **Create default config:**

```bash
smart-logger make-smart-logger-default-conf
```

---

## Folder Structure

```
smart_logger/
├── cli/
├── config/
├── core/
├── exceptions/
├── models/
├── security/
├── ui/
├── tests/
├── examples/
├── setup.py
├── pyproject.toml
├── setup.cfg
├── LICENSE
└── README.md
```

* `core/` → Logger class, DB handlers
* `ui/` → Dashboard server, templates, static files
* `cli/` → Commands for server launch, user management
* `models/` → SQLAlchemy models
* `security/` → Auth, middleware, blacklist token
* `config/` → Default and global configuration
* `tests/` → Unit and integration tests
* `examples/` → Usage examples

---

## Logging API

```python
from smart_logger import SmartLogger

logger = SmartLogger()

logger.info("Informational message")
logger.warning("Warning message")
logger.error("Error message")
logger.critical("Critical message")
logger.debug("Debugging message")
```

* **Folder and file auto-detection**: module name used if not provided
* **UUID generated for every log entry**
* **Database metadata** stored automatically

---

## Dashboard Features

* **Real-time log view**
* **Filter by:** date, time, UUID, log type
* **Charts:**

  * Daily/Monthly/Yearly error insights
  * Bar charts by log type
* **System info:** CPU, memory, uptime
* **Cards & Stats** for quick overview
* **Logout button** for secure access

---

## License

MIT License. See LICENSE file for details.

---

✅ **Key Points:**

1. **Step-by-step setup guide** added.
2. **Clear instructions** for installation and usage.
3. **Examples for FastAPI, Flask, Django** included.
4. **CLI instructions** for UI and DB initialization.
5. **Folder structure overview** for developers.
6. **Ready for PyPI** and GitHub documentation.
