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.create_client("shortlink-updater")
    service_client.sent("从 demo_function 发出的日志")


if __name__ == "__main__":
    # 初始化主客户端,只包含基础配置
    base_client = VictoriaLogsClient("192.168.164.31", project="shortlink-system")
    
    # 为不同服务创建子客户端
    main_client = base_client.create_client("main")
    updater_client = base_client.create_client("shortlink-updater")

    # 模拟模块日志
    demo_function()
    main_client.sent("主模块启动完成")
    updater_client.sent("短链更新成功")

    # 查询
    main_client.print_logs('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.2.tar.gz (6.9 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.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logvictorialogs-0.1.2.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

Hashes for logvictorialogs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e7afea971a7241808af13b1fa1e942ede728181fc844dc5ef45b8893fcd3d76b
MD5 d72b6a578a200d51c84c97bf516537bb
BLAKE2b-256 abd83f5aa258c1b9a287face2e540b61cd5f8062fcac4189deb69212e7fc106a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for logvictorialogs-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93d0f366f6dbd07044fea41f9ae4e06f6da5c5da676876ebd177e96db38424f3
MD5 fa8be05fb6e68a7d049b964b4b71f5a0
BLAKE2b-256 e21c402962a9aba5b29bbeb26ef34c8edc2ec2792d5ec66310c658b75b741d27

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