A loguru handler to send logs to Tencent Cloud CLS via Kafka
Project description
loguru-to-cls
A simple package to send loguru logs to Tencent Cloud CLS (Cloud Log Service) using the Kafka protocol.
Installation
Gitee (Recommended)
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:
pip install git+https://<your-token>@gitee.com/yourusername/loguru-to-cls.git
GitHub
pip install git+https://github.com/yourusername/loguru-to-cls.git
Or install from source:
pip install .
Usage
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).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loguru_to_cls_tencent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: loguru_to_cls_tencent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b3704e845e8734e594cfedd33783aaec023111ecb7a843dff4a17a06707a33e
|
|
| MD5 |
b8bda427e5b1b94f7cf4d295c8920dde
|
|
| BLAKE2b-256 |
955ffc0f395b99b299dabbc7b20f1c7d7b26f8f76b001c3efca10b1566c17d07
|