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 async_gelf_client import AsyncGelfUdpClient, create_gelf_message

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

asyncio.run(main())

API

AsyncGelfUdpClient

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

create_gelf_message

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

convert_python_log_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.1.0.tar.gz (4.3 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.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: async_gelf_client-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 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.1.0.tar.gz
Algorithm Hash digest
SHA256 0de1767ebf433b0187e4a0f29665b3ac7b37f453434c9fec1d6bc3b5893a7b1e
MD5 f921bfcb24a09ee41ed323393c736277
BLAKE2b-256 4ddfb625c59226bd38ecf9d02e242375a8fa5709e0b10d2e9503f6f095759cdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for async_gelf_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f30b52f12ec3ccd84182ce5d5f231f58988b36240dfd385f50169baab856454
MD5 95a5840d571b7d16e87d14bc695900f7
BLAKE2b-256 71895f1a8efccbdbcb93d5130bcad463b53e773dc3d40781cd684ca059a9a244

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