Metadata-Version: 2.4
Name: z_mongo_logger
Version: 0.1.0
Summary: Log messages to a MongoDB collection
Author-email: Mohamed Amin <mohamedamin.tech@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/mohamedaminkhaled/python-topics/tree/main/problems/mongo_logger
Keywords: mongodb,logging,mongo
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pymongo
Dynamic: license-file

# mongo_logger

A lightweight Python logger that writes messages to a MongoDB collection.

## Installation

```bash
pip install mongo_logger
```

## Configuration

Create a `config.json` file with your MongoDB connection details:

```json
{
    "LogConfig": {
        "Log_Mongo_Connection": "mongodb://localhost:27017",
        "Log_Database": "logs_db",
        "Log_Collection": "logs"
    }
}
```

## Usage

```python
from mongo_logger import MongoLogger

logger = MongoLogger(config_path="config.json", engine_name="my_app")
logger.z_log("Application started")
```

- `config_path` — path to your `config.json` (defaults to `config.json` in the script directory)
- `engine_name` — identifier for the logging source (defaults to the parent folder name)

## Document Schema

Each log entry is stored as a MongoDB document:

| Field         | Description                    |
|---------------|--------------------------------|
| `Engine_Name` | Name of the logging source     |
| `Status`      | The log message                |
| `Time`        | UTC timestamp of the log entry |

## License

MIT
