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.4.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.4-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logvictorialogs-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 a304e0b837678daa90accd5e18da41aa7002faede6c37ebd2f14dae217e2339b
MD5 1619d25d3d3be08024f0d21073515b93
BLAKE2b-256 5411b441fb206b11a97e04c48ec2afeae4fc19dabff803d575caa4f7e34fc1d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for logvictorialogs-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aacc8a3a60a37ae81a316cab3eca8b54193be37f81e2013083bf4da37bbbfa13
MD5 20765dc4397315d2e2a03dc9d95151d4
BLAKE2b-256 87b62757a3db78f309310d3cdc2210b13cbb72f091efba3aa08fa07364ece73a

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