Metadata-Version: 2.4
Name: pylogging-ext
Version: 0.1.0
Summary: 一个支持 异步、批量、重试、多通道通知 的 logging 扩展库。
Home-page: https://github.com/cnmax/pylogging-ext
Author: chao
Author-email: mr.qchao@gmail.com
License: MIT
Project-URL: Homepage, https://github.com/cnmax/pylogging-ext
Project-URL: Bug Tracker, https://github.com/cnmax/pylogging-ext/issues
Project-URL: Source Code, https://github.com/cnmax/pylogging-ext
Keywords: logging,async logging,handler,cls,tencent cloud,wechat,telegram,notification,monitoring
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
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: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Logging
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: tencentcloud-cls-sdk-python
Provides-Extra: socks
Requires-Dist: requests[socks]; extra == "socks"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary

# pylogging-ext

[![PyPI](https://img.shields.io/pypi/v/pylogging-ext.svg)](https://pypi.python.org/pypi/pylogging-ext)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pylogging-ext)
![PyPI - License](https://img.shields.io/pypi/l/pylogging-ext)
![GitHub last commit](https://img.shields.io/github/last-commit/cnmaxqi/pylogging-ext)

一个支持 异步、批量、重试、多通道通知 的 logging 扩展库。

> 不只是 logging handler，更是通知基础设施

## 安装

```bash
pip install pylogging-ext
```
可选（支持 socks 代理）：
```bash
pip install pylogging-ext[socks]
```

## 使用

```python
import logging
from pylogging_ext import TelegramHandler

logger = logging.getLogger('demo')
logger.setLevel(logging.INFO)

handler = TelegramHandler(
    token='your-bot-token',
    chat_id='your-chat-id',
)

logger.addHandler(handler)

logger.error('发生错误了')
```

## API

### Class: BaseHandler

通用异步 Handler 基类，所有通知 Handler 均继承自此类。

#### BaseHandler(...)

- `batch_size` 批量发送大小
- `flush_interval` 刷新间隔 (秒)
- `queue_size` 队列大小
- `retry` 重试次数

#### 特性：
- 异步发送（非阻塞）
- 批量处理
- 指数退避重试
- 优雅关闭

## 腾讯云 CLS
### Class: TencentCloudCLSHandler

```pycon
from pylogging_ext import TencentCloudCLSHandler

handler = TencentCloudCLSHandler(
    endpoint='ap-shanghai.cls.tencentcs.com',
    secret_id='your-secret-id',
    secret_key='your-secret-key',
    topic_id='your-topic-id',
)
```
### 参数
- `endpoint` CLS接入地址
- `secret_id` 腾讯云密钥
- `secret_key` 腾讯云密钥
- `topic_id` 日志主题 ID

## 微信机器人
### Class: WeChatHandler

```pycon
from pylogging_ext import WeChatHandler

handler = WeChatHandler(
    webhook='https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx'
)
```

### 参数
- `webhook` 企业微信机器人地址

## Telegram
### Class: TelegramHandler

```pycon
from pylogging_ext import TelegramHandler

handler = TelegramHandler(
    token='your-bot-token',
    chat_id='your-chat-id',
    proxies={
        'http': 'http://127.0.0.1:7890',
        'https': 'http://127.0.0.1:7890',
    }
)
```
### 参数
- `token` Telegram Bot Token
- `chat_id` 聊天 ID
- `proxies` 代理配置（可选）
- `ssl_verify` SSL校验 (默认 True)

## 支持的通知渠道
- 腾讯云 CLS
- 企业微信
- Telegram

持续扩展中...
