Python client for VictoriaLogs integration
Project description
LogVictoriaLogs
Python client library for integrating with VictoriaLogs, a high-performance log database and search solution.
Features
- Easy integration with VictoriaLogs
- Support for multiple logging protocols (HTTP, Syslog)
- Automatic caller information capture
- Python logging module integration
- Structured logging with rich context information
Installation
pip install LogVictoriaLogs
Usage
Basic Usage
# ----------------------------------------------------------------------
# 🎯 示例
# ----------------------------------------------------------------------
def demo_function():
# 初始化主客户端,只包含基础配置
base_client = VictoriaLogsClient("192.168.164.31", project="shortlink-system")
# 创建服务特定的客户端
service_client = base_client.CreateClient("shortlink-updater")
service_client.info("从 demo_function 发出的日志")
if __name__ == "__main__":
# 初始化主客户端,只包含基础配置
base_client = VictoriaLogsClient("192.168.164.31", project="shortlink-system")
# 为不同服务创建子客户端
main_client = base_client.CreateClient("main")
updater_client = base_client.CreateClient("shortlink-updater")
# 模拟模块日志
demo_function()
main_client.info("主模块启动完成")
updater_client.info("短链更新成功")
updater_client.warning("短链更新成功")
updater_client.error("短链更新失败")
# 查询
main_client.PrintLogs('project:"shortlink-system" service:"shortlink-updater"')
Python Logging Integration
import logging
from LogVictoriaLogs import VictoriaLogsClient
# Create client
client = VictoriaLogsClient("victorialogs-host", 9428, 514)
# Configure logging
logger = logging.getLogger("MyApp")
logger.setLevel(logging.INFO)
# Add VictoriaLogs handler
handler = client._setup_logging_handler(service="my-application")
logger.addHandler(handler)
# Use standard logging
logger.info("Application started")
logger.error("Something went wrong")
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
logvictorialogs-0.1.6.tar.gz
(6.9 kB
view details)
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 logvictorialogs-0.1.6.tar.gz.
File metadata
- Download URL: logvictorialogs-0.1.6.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
960c367475e2390de90d1f4b2960916589a96583e9385cc89bf46e7831d4299e
|
|
| MD5 |
501f1f3cc24a59d7a5ab3a4d55f0fa92
|
|
| BLAKE2b-256 |
5af2ebba5dcd298ea26a9b1482d93043b51ae29f62ae1cb3b2c7e20684aeaaff
|
File details
Details for the file logvictorialogs-0.1.6-py3-none-any.whl.
File metadata
- Download URL: logvictorialogs-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ed12e9b9404484b3d6e0beb7ab190cf58ae6b36cb380e718ae008de4e075491
|
|
| MD5 |
f7875a8c7183761813dd3a3e8585b005
|
|
| BLAKE2b-256 |
5beb01fcb6d24b7bdc91d70560486d22d43b04d46951d32e4ef922087af2924f
|