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("短链更新成功")

    # 查询
    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.3.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.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logvictorialogs-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 b4eb01e23ff3e60d61b187ca4e8943824397edd6b7aef0ff4922e57dd68bb3ff
MD5 58ff8484e030ae44e693b6d24e93a9ad
BLAKE2b-256 13b69f1978cc01185fbe6bd1ce21cda516c35fbda9586a4f5d7d8e3877f05a77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for logvictorialogs-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ee1652f9c9f5db16d302c42b07e044c7637e50d3613e433126d80251e93dafbb
MD5 3fce40bfa1080aeb091b7e91b74a8f5d
BLAKE2b-256 5968cd89b20546a523b1773d0b59d599e424ba374a7ca8bd91ef932bd645579c

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