Skip to main content

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.5.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logvictorialogs-0.1.5-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file logvictorialogs-0.1.5.tar.gz.

File metadata

  • Download URL: logvictorialogs-0.1.5.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for logvictorialogs-0.1.5.tar.gz
Algorithm Hash digest
SHA256 586d8f3a976e8e5c76f5d362a832117ad15737e37fe679e9e314365a9faa5070
MD5 5495db084c2e9e6b1af28b5162ffc48d
BLAKE2b-256 21d9c1491a85c7c9956583ae1b5c953120eba1da706adcc32cfcbdfd61c0d655

See more details on using hashes here.

File details

Details for the file logvictorialogs-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for logvictorialogs-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dc90bf1814a502d94c847eb412599e95bc0c9b33e75a30d519b2a74567cf059b
MD5 d213ea583d613f49ab1ddcdbb772cc11
BLAKE2b-256 ab087f486dcdaa89a33b4c1f8632a372eaf3128b7cf0d4dec0ce6273631ae4e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page