Skip to main content

Async UDP client for sending GELF messages to Graylog

Project description

Async GELF Client

Async UDP client for sending GELF messages to Graylog. Uses native asyncio for maximum performance and automatically compresses messages larger than 8KB.

Installation

pip install async-gelf-client

Usage

import asyncio
from asyncgelf import AsyncGelfClient, GelfMessage

async def main():
    client = AsyncGelfClient(host="localhost", port=12201)
    
    message = GelfMessage.create(
        short_message="Hello Graylog",
        level=6,
        host="myapp"
    )
    
    await client.send(message)

asyncio.run(main())

API

AsyncGelfClient

Async UDP client for sending GELF messages.

Parameters:

  • host (str): Graylog server hostname or IP address
  • port (int): UDP port (default: 12201)
  • compress_threshold (int): Message size in bytes to trigger compression (default: 8192)

Methods:

  • async send(message: dict[str, Any]) -> None: Sends GELF message

GelfMessage

GELF message builder with static methods.

Methods:

GelfMessage.create(...)

Creates a properly formatted GELF message.

Parameters:

  • short_message (str): Short log description (required)
  • full_message (str | None): Full log description (optional)
  • level (int): Syslog level (7=debug, 6=info, 4=warning, 3=error, 2=critical)
  • host (str): Host/application name
  • timestamp (float | None): Unix timestamp (if None - current time)
  • **additional_fields: Additional fields (will be prefixed with _)

Returns: dict with GELF message

GelfMessage.convert_log_level(python_level)

Converts Python logging level to Syslog level for GELF.

Parameters:

  • python_level (int): Python logging level (logging.DEBUG, logging.INFO, etc.)

Returns: int - Syslog level

Requirements

  • Python >= 3.10

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

async_gelf_client-0.2.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

async_gelf_client-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file async_gelf_client-0.2.0.tar.gz.

File metadata

  • Download URL: async_gelf_client-0.2.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for async_gelf_client-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1d9654710ebe19218d04fe224b7c38439b791fd95ef3d8aadb236ed5dfe7f6d4
MD5 d5e7d588fcfbc5c61d43ba73aef18049
BLAKE2b-256 fb33949441fb39f1fea2129b4e1b870bd20e58540b46194380ed92a95fdff200

See more details on using hashes here.

File details

Details for the file async_gelf_client-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for async_gelf_client-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 750f1fba5ca0303beb0e45bf59fdcd2e5c466a359a95598d904133a35131c46c
MD5 7311b383536d69bae36be84f501187bf
BLAKE2b-256 341e9027813f349efa666507f8e37c6a148fa9b5f404aea7aa15f1a5514830a9

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