Metadata-Version: 2.1
Name: loguru-to-cls-tencent
Version: 0.1.1
Summary: A loguru handler to send logs to Tencent Cloud CLS via Kafka
Home-page: https://gitee.com/linzeming/loguru-to-cls
Author: linzeming
Author-email: linzeming@example.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: loguru
Requires-Dist: kafka-python

# loguru-to-cls

A simple package to send [loguru](https://github.com/Delgan/loguru) logs to Tencent Cloud CLS (Cloud Log Service) using the Kafka protocol.

## Installation

### Gitee (Recommended)
```bash
pip install git+https://gitee.com/yourusername/loguru-to-cls.git
```

### Private Repository (No Login Prompt)

If the repository is private, use a **Personal Access Token**:

```bash
pip install git+https://<your-token>@gitee.com/yourusername/loguru-to-cls.git
```

### GitHub
```bash
pip install git+https://github.com/yourusername/loguru-to-cls.git
```

Or install from source:

```bash
pip install .
```

## Usage

```python
from loguru import logger
from loguru_to_cls import setup_cls_logging

# Initialize CLS logging
secret_id = "YOUR_SECRET_ID"
secret_key = "YOUR_SECRET_KEY"
logset_id = "YOUR_LOGSET_ID"
topic_id = "YOUR_TOPIC_ID"

handler = setup_cls_logging(secret_id, secret_key, logset_id, topic_id)

# Now you can use loguru as usual
logger.info("This is a test log message sent to Tencent Cloud CLS!")
logger.error("This is an error message.")

# Ensure all logs are sent before exiting
handler.flush()
```

## Configuration

The `setup_cls_logging` function accepts the following parameters:

- `secret_id`: Tencent Cloud Secret ID.
- `secret_key`: Tencent Cloud Secret Key.
- `logset_id`: CLS Logset ID.
- `topic_id`: CLS Topic ID.
- `level`: Logging level (default: "INFO").
- `bootstrap_servers`: List of Kafka bootstrap servers (default: Tencent Cloud Guangzhou region).


