Metadata-Version: 2.4
Name: async-gelf-client
Version: 0.2.0
Summary: Async UDP client for sending GELF messages to Graylog
Author-email: Ivan Sheiko <gazziiii777@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/gazziiii777
Project-URL: Repository, https://github.com/gazziiii777/async-gelf-client
Keywords: gelf,graylog,logging,async,udp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Logging
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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

```bash
pip install async-gelf-client
```

## Usage

```python
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
