Name | loglito JSON |
Version |
0.1.3
JSON |
| download |
home_page | https://loglito.io |
Summary | Python client library for Loglito logging service |
upload_time | 2025-07-19 21:07:31 |
maintainer | None |
docs_url | None |
author | Loglito Team |
requires_python | >=3.7 |
license | MIT License
Copyright (c) 2024 Loglito Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
logging
loglito
observability
monitoring
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Loglito Python Client
[](https://badge.fury.io/py/loglito)
[](https://pypi.org/project/loglito/)
[](https://opensource.org/licenses/MIT)
The official Python client library for [Loglito](https://loglito.io), a powerful logging and observability platform.
## Installation
Install the Loglito Python client using pip:
```bash
pip install loglito
```
## Quick Start
```python
from loglito import Loglito
# Initialize the client with your API key
loglito = Loglito(api_key="your-api-key-here")
# Simple logging
loglito.log("Hello world!")
# Level, message, and data dictionary
loglito.log("info", "User subscribed", {"user_id": 123, "plan": "premium"})
# NEW: Convenient shortcut methods for different log levels
loglito.info("User logged in", {"user_id": 2132})
loglito.debug("API response", {"status": 200, "endpoint": "/users"})
loglito.warning("Rate limit approaching", {"current_usage": 85, "limit": 100})
loglito.error("Database connection failed", {"error": "timeout", "retries": 3})
# Traditional structured logging with data (still supported)
loglito.log(message="User logged in", data={
"username": "john",
"ip_address": "192.168.1.1"
})
# Log with specific level using new format
loglito.log("warning", "Low disk space", {
"disk_usage": "85%",
"server": "web-01"
})
```
## Shortcut Methods
For convenience, the client provides shortcut methods for common log levels:
```python
from loglito import Loglito
loglito = Loglito(api_key="your-api-key")
# Info level logging
loglito.info("User logged in", {"user_id": 2132})
# Debug level logging
loglito.debug("SQL query executed", {
"query": "SELECT * FROM users WHERE id = ?",
"params": [123],
"execution_time": 0.045
})
# Warning level logging
loglito.warning("Rate limit approaching", {
"current_usage": 85,
"limit": 100,
"user_id": 456
})
# Error level logging
loglito.error("Payment processing failed", {
"error": "card_declined",
"order_id": "ORD-789",
"amount": 99.99
})
# You can also pass additional keyword arguments
loglito.info("File uploaded", {"file_size": 1024}, file_type="image/jpeg", user_id=123)
```
These shortcut methods are equivalent to calling `loglito.log(level, message, data)` but provide a more convenient and readable interface.
## Configuration
### Basic Configuration
```python
from loglito import Loglito
loglito = Loglito(
api_key="your-api-key",
base_url="https://api.loglito.io", # Custom API endpoint
timeout=30.0, # Request timeout in seconds
retries=3, # Number of retry attempts
verify_ssl=True # SSL certificate verification
)
```
### Performance Configuration (Buffering)
The client uses intelligent buffering for optimal performance:
```python
loglito = Loglito(
api_key="your-api-key",
buffer_size=100, # Flush after 100 logs
flush_interval=2.0, # Flush every 2 seconds
immediate_mode=False # Use buffering (default)
)
# For real-time logging (no buffering)
loglito_immediate = Loglito(
api_key="your-api-key",
immediate_mode=True
)
```
### Default Data
You can configure default data that will be automatically included in all log entries:
```python
# Set default data that will be included in ALL logs
loglito = Loglito(
api_key="your-api-key",
data={
"project": "nextsearch",
"version": "1.0.2",
"environment": "production",
"service": "user-authentication"
}
)
# All logs will now include the default data
loglito.log("User login")
# Results in: {"__message": "User login", "project": "nextsearch", "version": "1.0.2", ...}
loglito.log("info", "Payment processed", {"amount": 99.99})
# Results in: {"__level": "info", "__message": "Payment processed", "amount": 99.99, "project": "nextsearch", ...}
# Specific log data can override default data
loglito.log("warning", "Test environment issue", {"environment": "testing"})
# The "environment" field will be "testing" instead of "production"
```
### Environment Variables
You can also configure the client using environment variables:
```bash
export LOGLITO_API_KEY="your-api-key"
export LOGLITO_BASE_URL="https://api.loglito.io"
```
```python
import os
from loglito import Loglito
loglito = Loglito(
api_key=os.getenv("LOGLITO_API_KEY"),
base_url=os.getenv("LOGLITO_BASE_URL", "https://loglito.io")
)
```
## Usage Examples
### Multiple Calling Patterns
The `log()` method supports several flexible calling patterns:
```python
from loglito import Loglito
loglito = Loglito(api_key="your-api-key")
# 1. Simple string message
loglito.log("Application started")
# 2. Level, message, and data dictionary (RECOMMENDED)
loglito.log("info", "User subscribed", {"user_id": 123, "plan": "premium"})
# 3. Level, message, and multiple data dictionaries
loglito.log("info", "User action",
{"user_id": 123},
{"action": "file_upload"},
{"file_size": 1024})
# 4. Traditional keyword arguments (still supported)
loglito.log(level="info", message="User authentication successful")
# 5. Mixed approach with additional keyword arguments
loglito.log("error", "Payment failed",
{"order_id": "12345", "amount": 99.99},
retry_count=3,
processor="stripe")
# 6. Just data without message
loglito.log("debug", "", {
"function": "calculate_total",
"execution_time": 0.045,
"result": 1250.50
})
```
### API Payload Format
All logs are sent to the API in a consistent batch format:
```json
{
"logs": [
{
"log": {
"__date": "2024-01-15T10:30:00.123Z",
"__message": "User subscribed",
"__level": "info",
"user_id": 123,
"plan": "premium"
}
}
]
}
```
### Structured Logging
```python
# E-commerce example using new format
loglito.log(
"info",
"Order placed",
{
"order_id": "ORD-12345",
"customer_id": "CUST-789",
"total_amount": 99.99,
"items": [
{"product": "Widget A", "quantity": 2, "price": 29.99},
{"product": "Widget B", "quantity": 1, "price": 39.99}
],
"payment_method": "credit_card",
"shipping_address": {
"city": "New York",
"state": "NY",
"zip": "10001"
}
}
)
# Error logging with context
loglito.log(
"error",
"Database connection failed",
{
"error_type": "ConnectionTimeout",
"database": "postgres",
"host": "db.example.com",
"retry_count": 3,
"port": 5432
}
)
# Debug logging for performance monitoring
loglito.log(
"debug",
"API response time",
{
"endpoint": "/api/users",
"method": "GET",
"response_time": 0.245,
"status_code": 200,
"user_id": 123
}
)
```
### Batch Logging
For high-volume applications, use batch logging to send multiple logs in a single request:
```python
logs = [
{
"message": "User login",
"level": "info",
"data": {"user_id": 123, "ip": "192.168.1.1"}
},
{
"message": "Page view",
"level": "debug",
"data": {"page": "/dashboard", "user_id": 123}
},
{
"message": "API call",
"level": "info",
"data": {"endpoint": "/api/users", "method": "GET", "status": 200}
}
]
loglito.log_batch(logs)
```
### Using Keyword Arguments
You can also pass additional fields directly as keyword arguments:
```python
# Using new format with keyword arguments
loglito.log(
"info",
"User action",
{"user_id": 123, "action": "file_upload"},
file_size=1024000,
file_type="image/jpeg",
success=True
)
# Traditional keyword approach (still supported)
loglito.log(
message="User action",
level="info",
data={"user_id": 123},
action="file_upload",
file_size=1024000
)
```
### Context Manager
Use the client as a context manager to ensure proper cleanup:
```python
with Loglito(api_key="your-api-key") as loglito:
loglito.log("info", "Application starting", {"version": "1.0.0"})
# ... your application code ...
loglito.log("info", "Application shutting down", {"uptime": 3600})
# Session is automatically closed
```
## API Reference
### Loglito Class
#### Constructor
```python
Loglito(
api_key: str,
base_url: str = "https://loglito.io",
timeout: float = 30.0,
retries: int = 3,
verify_ssl: bool = True
)
```
**Parameters:**
- `api_key` (str): Your Loglito API key (required)
- `base_url` (str): Base URL for the Loglito API
- `timeout` (float): Request timeout in seconds
- `retries` (int): Number of retry attempts for failed requests
- `verify_ssl` (bool): Whether to verify SSL certificates
#### Methods
##### `log(*args, **kwargs)`
Send a single log entry to Loglito.
**Calling Patterns:**
- `log("message")` - Simple message
- `log("level", "message", data_dict)` - Level, message, and data (recommended)
- `log("level", "message", dict1, dict2, ...)` - Multiple data dictionaries
- `log(level="info", message="text", data={...})` - Keyword arguments (legacy)
**Parameters:**
- `*args`: Positional arguments - level, message, and data dictionaries
- `**kwargs`: Keyword arguments including:
- `level` (str, optional): Log level (e.g., "info", "warning", "error", "debug")
- `message` (str, optional): Log message
- `data` (dict, optional): Additional structured data
- Additional key-value pairs to include in the log
**Returns:** `bool` - True if successful, False otherwise
##### `log_batch(logs)`
Send multiple log entries in a single request.
**Parameters:**
- `logs` (list): List of log dictionaries
**Returns:** `bool` - True if successful, False otherwise
##### `test_connection()`
Test the connection to Loglito by sending a test log.
**Returns:** `bool` - True if connection is successful, False otherwise
##### `close()`
Close the underlying HTTP session.
##### `info(message, data=None, **kwargs)`
Send an info level log entry.
**Parameters:**
- `message` (str): Log message
- `data` (dict, optional): Additional structured data
- `**kwargs`: Additional key-value pairs to include in the log
**Returns:** `bool` - True if successful, False otherwise
##### `debug(message, data=None, **kwargs)`
Send a debug level log entry.
**Parameters:**
- `message` (str): Log message
- `data` (dict, optional): Additional structured data
- `**kwargs`: Additional key-value pairs to include in the log
**Returns:** `bool` - True if successful, False otherwise
##### `warning(message, data=None, **kwargs)`
Send a warning level log entry.
**Parameters:**
- `message` (str): Log message
- `data` (dict, optional): Additional structured data
- `**kwargs`: Additional key-value pairs to include in the log
**Returns:** `bool` - True if successful, False otherwise
##### `error(message, data=None, **kwargs)`
Send an error level log entry.
**Parameters:**
- `message` (str): Log message
- `data` (dict, optional): Additional structured data
- `**kwargs`: Additional key-value pairs to include in the log
**Returns:** `bool` - True if successful, False otherwise
##### `log_batch(logs)`
## Error Handling
The client provides specific exception types for different error scenarios:
```python
from loglito import Loglito, LoglitoError, LoglitoAuthenticationError, LoglitoConnectionError
try:
loglito = Loglito(api_key="invalid-key")
loglito.log("info", "Test message", {"test": True})
except LoglitoAuthenticationError:
print("Invalid API key")
except LoglitoConnectionError:
print("Connection failed")
except LoglitoError:
print("General Loglito error")
```
## Integration Examples
### Flask Application
```python
from flask import Flask
from loglito import Loglito
app = Flask(__name__)
loglito = Loglito(api_key="your-api-key")
@app.route('/user/<int:user_id>')
def get_user(user_id):
loglito.log(
"info",
"User profile accessed",
{
"user_id": user_id,
"endpoint": "/user",
"method": "GET"
}
)
# ... your application logic ...
```
### Django Application
```python
# settings.py
LOGLITO_API_KEY = "your-api-key"
# views.py
from django.conf import settings
from loglito import Loglito
loglito = Loglito(api_key=settings.LOGLITO_API_KEY)
def user_login(request):
# ... authentication logic ...
loglito.log(
"info",
"User logged in",
{
"user_id": user.id,
"username": user.username,
"ip_address": request.META.get('REMOTE_ADDR')
}
)
```
### FastAPI Application
```python
from fastapi import FastAPI
from loglito import Loglito
app = FastAPI()
loglito = Loglito(api_key="your-api-key")
@app.post("/api/orders")
async def create_order(order_data: dict):
loglito.log(
"info",
"Order created",
{
"order_id": order_data.get("id"),
"customer_id": order_data.get("customer_id"),
"total": order_data.get("total")
}
)
# ... your application logic ...
```
## Development
### Setting up Development Environment
```bash
# Clone the repository
git clone https://github.com/loglito/loglito-python.git
cd loglito-python
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
```
### Running Tests
```bash
pytest
```
### Code Formatting
```bash
black loglito/
```
## Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- 📖 [Documentation](https://loglito.io/docs)
- 💬 [Community Discord](https://discord.gg/loglito)
- 🐛 [Issue Tracker](https://github.com/loglito/loglito-python/issues)
- 📧 [Email Support](mailto:support@loglito.io)
## Changelog
### v0.1.0
- Initial release
- Basic logging functionality
- Batch logging support
- Error handling and retries
- Context manager support
Raw data
{
"_id": null,
"home_page": "https://loglito.io",
"name": "loglito",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "logging, loglito, observability, monitoring",
"author": "Loglito Team",
"author_email": "Loglito Team <hello@loglito.io>",
"download_url": "https://files.pythonhosted.org/packages/95/c2/ed432272e4948eea9a96323952e52a4a402a449f3ea095a80f9461f9c504/loglito-0.1.3.tar.gz",
"platform": null,
"description": "# Loglito Python Client\n\n[](https://badge.fury.io/py/loglito)\n[](https://pypi.org/project/loglito/)\n[](https://opensource.org/licenses/MIT)\n\nThe official Python client library for [Loglito](https://loglito.io), a powerful logging and observability platform.\n\n## Installation\n\nInstall the Loglito Python client using pip:\n\n```bash\npip install loglito\n```\n\n## Quick Start\n\n```python\nfrom loglito import Loglito\n\n# Initialize the client with your API key\nloglito = Loglito(api_key=\"your-api-key-here\")\n\n# Simple logging\nloglito.log(\"Hello world!\")\n\n# Level, message, and data dictionary\nloglito.log(\"info\", \"User subscribed\", {\"user_id\": 123, \"plan\": \"premium\"})\n\n# NEW: Convenient shortcut methods for different log levels\nloglito.info(\"User logged in\", {\"user_id\": 2132})\nloglito.debug(\"API response\", {\"status\": 200, \"endpoint\": \"/users\"})\nloglito.warning(\"Rate limit approaching\", {\"current_usage\": 85, \"limit\": 100})\nloglito.error(\"Database connection failed\", {\"error\": \"timeout\", \"retries\": 3})\n\n# Traditional structured logging with data (still supported)\nloglito.log(message=\"User logged in\", data={\n \"username\": \"john\",\n \"ip_address\": \"192.168.1.1\"\n})\n\n# Log with specific level using new format\nloglito.log(\"warning\", \"Low disk space\", {\n \"disk_usage\": \"85%\",\n \"server\": \"web-01\"\n})\n```\n\n## Shortcut Methods\n\nFor convenience, the client provides shortcut methods for common log levels:\n\n```python\nfrom loglito import Loglito\n\nloglito = Loglito(api_key=\"your-api-key\")\n\n# Info level logging\nloglito.info(\"User logged in\", {\"user_id\": 2132})\n\n# Debug level logging \nloglito.debug(\"SQL query executed\", {\n \"query\": \"SELECT * FROM users WHERE id = ?\",\n \"params\": [123],\n \"execution_time\": 0.045\n})\n\n# Warning level logging\nloglito.warning(\"Rate limit approaching\", {\n \"current_usage\": 85,\n \"limit\": 100,\n \"user_id\": 456\n})\n\n# Error level logging\nloglito.error(\"Payment processing failed\", {\n \"error\": \"card_declined\",\n \"order_id\": \"ORD-789\",\n \"amount\": 99.99\n})\n\n# You can also pass additional keyword arguments\nloglito.info(\"File uploaded\", {\"file_size\": 1024}, file_type=\"image/jpeg\", user_id=123)\n```\n\nThese shortcut methods are equivalent to calling `loglito.log(level, message, data)` but provide a more convenient and readable interface.\n\n## Configuration\n\n### Basic Configuration\n\n```python\nfrom loglito import Loglito\n\nloglito = Loglito(\n api_key=\"your-api-key\",\n base_url=\"https://api.loglito.io\", # Custom API endpoint\n timeout=30.0, # Request timeout in seconds\n retries=3, # Number of retry attempts\n verify_ssl=True # SSL certificate verification\n)\n```\n\n### Performance Configuration (Buffering)\n\nThe client uses intelligent buffering for optimal performance:\n\n```python\nloglito = Loglito(\n api_key=\"your-api-key\",\n buffer_size=100, # Flush after 100 logs\n flush_interval=2.0, # Flush every 2 seconds\n immediate_mode=False # Use buffering (default)\n)\n\n# For real-time logging (no buffering)\nloglito_immediate = Loglito(\n api_key=\"your-api-key\",\n immediate_mode=True\n)\n```\n\n### Default Data\n\nYou can configure default data that will be automatically included in all log entries:\n\n```python\n# Set default data that will be included in ALL logs\nloglito = Loglito(\n api_key=\"your-api-key\",\n data={\n \"project\": \"nextsearch\",\n \"version\": \"1.0.2\", \n \"environment\": \"production\",\n \"service\": \"user-authentication\"\n }\n)\n\n# All logs will now include the default data\nloglito.log(\"User login\")\n# Results in: {\"__message\": \"User login\", \"project\": \"nextsearch\", \"version\": \"1.0.2\", ...}\n\nloglito.log(\"info\", \"Payment processed\", {\"amount\": 99.99})\n# Results in: {\"__level\": \"info\", \"__message\": \"Payment processed\", \"amount\": 99.99, \"project\": \"nextsearch\", ...}\n\n# Specific log data can override default data\nloglito.log(\"warning\", \"Test environment issue\", {\"environment\": \"testing\"})\n# The \"environment\" field will be \"testing\" instead of \"production\"\n```\n\n### Environment Variables\n\nYou can also configure the client using environment variables:\n\n```bash\nexport LOGLITO_API_KEY=\"your-api-key\"\nexport LOGLITO_BASE_URL=\"https://api.loglito.io\"\n```\n\n```python\nimport os\nfrom loglito import Loglito\n\nloglito = Loglito(\n api_key=os.getenv(\"LOGLITO_API_KEY\"),\n base_url=os.getenv(\"LOGLITO_BASE_URL\", \"https://loglito.io\")\n)\n```\n\n## Usage Examples\n\n### Multiple Calling Patterns\n\nThe `log()` method supports several flexible calling patterns:\n\n```python\nfrom loglito import Loglito\n\nloglito = Loglito(api_key=\"your-api-key\")\n\n# 1. Simple string message\nloglito.log(\"Application started\")\n\n# 2. Level, message, and data dictionary (RECOMMENDED)\nloglito.log(\"info\", \"User subscribed\", {\"user_id\": 123, \"plan\": \"premium\"})\n\n# 3. Level, message, and multiple data dictionaries\nloglito.log(\"info\", \"User action\", \n {\"user_id\": 123}, \n {\"action\": \"file_upload\"}, \n {\"file_size\": 1024})\n\n# 4. Traditional keyword arguments (still supported)\nloglito.log(level=\"info\", message=\"User authentication successful\")\n\n# 5. Mixed approach with additional keyword arguments\nloglito.log(\"error\", \"Payment failed\", \n {\"order_id\": \"12345\", \"amount\": 99.99},\n retry_count=3,\n processor=\"stripe\")\n\n# 6. Just data without message\nloglito.log(\"debug\", \"\", {\n \"function\": \"calculate_total\",\n \"execution_time\": 0.045,\n \"result\": 1250.50\n})\n```\n\n### API Payload Format\n\nAll logs are sent to the API in a consistent batch format:\n\n```json\n{\n \"logs\": [\n {\n \"log\": {\n \"__date\": \"2024-01-15T10:30:00.123Z\",\n \"__message\": \"User subscribed\",\n \"__level\": \"info\",\n \"user_id\": 123,\n \"plan\": \"premium\"\n }\n }\n ]\n}\n```\n\n### Structured Logging\n\n```python\n# E-commerce example using new format\nloglito.log(\n \"info\",\n \"Order placed\",\n {\n \"order_id\": \"ORD-12345\",\n \"customer_id\": \"CUST-789\",\n \"total_amount\": 99.99,\n \"items\": [\n {\"product\": \"Widget A\", \"quantity\": 2, \"price\": 29.99},\n {\"product\": \"Widget B\", \"quantity\": 1, \"price\": 39.99}\n ],\n \"payment_method\": \"credit_card\",\n \"shipping_address\": {\n \"city\": \"New York\",\n \"state\": \"NY\",\n \"zip\": \"10001\"\n }\n }\n)\n\n# Error logging with context\nloglito.log(\n \"error\",\n \"Database connection failed\",\n {\n \"error_type\": \"ConnectionTimeout\",\n \"database\": \"postgres\", \n \"host\": \"db.example.com\",\n \"retry_count\": 3, \n \"port\": 5432\n }\n)\n\n# Debug logging for performance monitoring\nloglito.log(\n \"debug\",\n \"API response time\",\n {\n \"endpoint\": \"/api/users\",\n \"method\": \"GET\",\n \"response_time\": 0.245,\n \"status_code\": 200,\n \"user_id\": 123\n }\n)\n```\n\n### Batch Logging\n\nFor high-volume applications, use batch logging to send multiple logs in a single request:\n\n```python\nlogs = [\n {\n \"message\": \"User login\",\n \"level\": \"info\",\n \"data\": {\"user_id\": 123, \"ip\": \"192.168.1.1\"}\n },\n {\n \"message\": \"Page view\",\n \"level\": \"debug\",\n \"data\": {\"page\": \"/dashboard\", \"user_id\": 123}\n },\n {\n \"message\": \"API call\",\n \"level\": \"info\",\n \"data\": {\"endpoint\": \"/api/users\", \"method\": \"GET\", \"status\": 200}\n }\n]\n\nloglito.log_batch(logs)\n```\n\n### Using Keyword Arguments\n\nYou can also pass additional fields directly as keyword arguments:\n\n```python\n# Using new format with keyword arguments\nloglito.log(\n \"info\",\n \"User action\",\n {\"user_id\": 123, \"action\": \"file_upload\"},\n file_size=1024000,\n file_type=\"image/jpeg\",\n success=True\n)\n\n# Traditional keyword approach (still supported)\nloglito.log(\n message=\"User action\",\n level=\"info\",\n data={\"user_id\": 123},\n action=\"file_upload\",\n file_size=1024000\n)\n```\n\n### Context Manager\n\nUse the client as a context manager to ensure proper cleanup:\n\n```python\nwith Loglito(api_key=\"your-api-key\") as loglito:\n loglito.log(\"info\", \"Application starting\", {\"version\": \"1.0.0\"})\n # ... your application code ...\n loglito.log(\"info\", \"Application shutting down\", {\"uptime\": 3600})\n# Session is automatically closed\n```\n\n## API Reference\n\n### Loglito Class\n\n#### Constructor\n\n```python\nLoglito(\n api_key: str,\n base_url: str = \"https://loglito.io\",\n timeout: float = 30.0,\n retries: int = 3,\n verify_ssl: bool = True\n)\n```\n\n**Parameters:**\n- `api_key` (str): Your Loglito API key (required)\n- `base_url` (str): Base URL for the Loglito API\n- `timeout` (float): Request timeout in seconds\n- `retries` (int): Number of retry attempts for failed requests\n- `verify_ssl` (bool): Whether to verify SSL certificates\n\n#### Methods\n\n##### `log(*args, **kwargs)`\n\nSend a single log entry to Loglito.\n\n**Calling Patterns:**\n- `log(\"message\")` - Simple message\n- `log(\"level\", \"message\", data_dict)` - Level, message, and data (recommended)\n- `log(\"level\", \"message\", dict1, dict2, ...)` - Multiple data dictionaries\n- `log(level=\"info\", message=\"text\", data={...})` - Keyword arguments (legacy)\n\n**Parameters:**\n- `*args`: Positional arguments - level, message, and data dictionaries\n- `**kwargs`: Keyword arguments including:\n - `level` (str, optional): Log level (e.g., \"info\", \"warning\", \"error\", \"debug\")\n - `message` (str, optional): Log message\n - `data` (dict, optional): Additional structured data\n - Additional key-value pairs to include in the log\n\n**Returns:** `bool` - True if successful, False otherwise\n\n##### `log_batch(logs)`\n\nSend multiple log entries in a single request.\n\n**Parameters:**\n- `logs` (list): List of log dictionaries\n\n**Returns:** `bool` - True if successful, False otherwise\n\n##### `test_connection()`\n\nTest the connection to Loglito by sending a test log.\n\n**Returns:** `bool` - True if connection is successful, False otherwise\n\n##### `close()`\n\nClose the underlying HTTP session.\n\n##### `info(message, data=None, **kwargs)`\n\nSend an info level log entry.\n\n**Parameters:**\n- `message` (str): Log message\n- `data` (dict, optional): Additional structured data\n- `**kwargs`: Additional key-value pairs to include in the log\n\n**Returns:** `bool` - True if successful, False otherwise\n\n##### `debug(message, data=None, **kwargs)`\n\nSend a debug level log entry.\n\n**Parameters:**\n- `message` (str): Log message\n- `data` (dict, optional): Additional structured data\n- `**kwargs`: Additional key-value pairs to include in the log\n\n**Returns:** `bool` - True if successful, False otherwise\n\n##### `warning(message, data=None, **kwargs)`\n\nSend a warning level log entry.\n\n**Parameters:**\n- `message` (str): Log message\n- `data` (dict, optional): Additional structured data\n- `**kwargs`: Additional key-value pairs to include in the log\n\n**Returns:** `bool` - True if successful, False otherwise\n\n##### `error(message, data=None, **kwargs)`\n\nSend an error level log entry.\n\n**Parameters:**\n- `message` (str): Log message\n- `data` (dict, optional): Additional structured data\n- `**kwargs`: Additional key-value pairs to include in the log\n\n**Returns:** `bool` - True if successful, False otherwise\n\n##### `log_batch(logs)`\n\n## Error Handling\n\nThe client provides specific exception types for different error scenarios:\n\n```python\nfrom loglito import Loglito, LoglitoError, LoglitoAuthenticationError, LoglitoConnectionError\n\ntry:\n loglito = Loglito(api_key=\"invalid-key\")\n loglito.log(\"info\", \"Test message\", {\"test\": True})\nexcept LoglitoAuthenticationError:\n print(\"Invalid API key\")\nexcept LoglitoConnectionError:\n print(\"Connection failed\")\nexcept LoglitoError:\n print(\"General Loglito error\")\n```\n\n## Integration Examples\n\n### Flask Application\n\n```python\nfrom flask import Flask\nfrom loglito import Loglito\n\napp = Flask(__name__)\nloglito = Loglito(api_key=\"your-api-key\")\n\n@app.route('/user/<int:user_id>')\ndef get_user(user_id):\n loglito.log(\n \"info\",\n \"User profile accessed\",\n {\n \"user_id\": user_id,\n \"endpoint\": \"/user\",\n \"method\": \"GET\"\n }\n )\n # ... your application logic ...\n```\n\n### Django Application\n\n```python\n# settings.py\nLOGLITO_API_KEY = \"your-api-key\"\n\n# views.py\nfrom django.conf import settings\nfrom loglito import Loglito\n\nloglito = Loglito(api_key=settings.LOGLITO_API_KEY)\n\ndef user_login(request):\n # ... authentication logic ...\n \n loglito.log(\n \"info\",\n \"User logged in\",\n {\n \"user_id\": user.id,\n \"username\": user.username,\n \"ip_address\": request.META.get('REMOTE_ADDR')\n }\n )\n```\n\n### FastAPI Application\n\n```python\nfrom fastapi import FastAPI\nfrom loglito import Loglito\n\napp = FastAPI()\nloglito = Loglito(api_key=\"your-api-key\")\n\n@app.post(\"/api/orders\")\nasync def create_order(order_data: dict):\n loglito.log(\n \"info\",\n \"Order created\",\n {\n \"order_id\": order_data.get(\"id\"),\n \"customer_id\": order_data.get(\"customer_id\"),\n \"total\": order_data.get(\"total\")\n }\n )\n # ... your application logic ...\n```\n\n## Development\n\n### Setting up Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/loglito/loglito-python.git\ncd loglito-python\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate # On Windows: venv\\Scripts\\activate\n\n# Install development dependencies\npip install -e \".[dev]\"\n```\n\n### Running Tests\n\n```bash\npytest\n```\n\n### Code Formatting\n\n```bash\nblack loglito/\n```\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- \ud83d\udcd6 [Documentation](https://loglito.io/docs) \n- \ud83d\udcac [Community Discord](https://discord.gg/loglito)\n- \ud83d\udc1b [Issue Tracker](https://github.com/loglito/loglito-python/issues)\n- \ud83d\udce7 [Email Support](mailto:support@loglito.io)\n\n## Changelog\n\n### v0.1.0\n- Initial release\n- Basic logging functionality\n- Batch logging support\n- Error handling and retries\n- Context manager support\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2024 Loglito Team\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE. ",
"summary": "Python client library for Loglito logging service",
"version": "0.1.3",
"project_urls": {
"Documentation": "https://loglito.io/docs",
"Homepage": "https://loglito.io",
"Issues": "https://github.com/loglito/loglito-python/issues",
"Repository": "https://github.com/loglito/loglito-python"
},
"split_keywords": [
"logging",
" loglito",
" observability",
" monitoring"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "22e655a2414072493cec3c2fec3824f94c7c7d9c3c134d81760d9bfdee985c80",
"md5": "906762f61f7f5c26fb9ef86d77fd7ae1",
"sha256": "7f7fc0ce862603b8665d35ff52e15269c2d08531ea3a270bde791e2500c0b679"
},
"downloads": -1,
"filename": "loglito-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "906762f61f7f5c26fb9ef86d77fd7ae1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 13048,
"upload_time": "2025-07-19T21:07:29",
"upload_time_iso_8601": "2025-07-19T21:07:29.884384Z",
"url": "https://files.pythonhosted.org/packages/22/e6/55a2414072493cec3c2fec3824f94c7c7d9c3c134d81760d9bfdee985c80/loglito-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "95c2ed432272e4948eea9a96323952e52a4a402a449f3ea095a80f9461f9c504",
"md5": "3e1676a24966f621792f7862368cbec0",
"sha256": "5399c5dfcfd3f5008ee90441d462c639b08faed5b388c0a1cb982711990bee56"
},
"downloads": -1,
"filename": "loglito-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "3e1676a24966f621792f7862368cbec0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 19876,
"upload_time": "2025-07-19T21:07:31",
"upload_time_iso_8601": "2025-07-19T21:07:31.629487Z",
"url": "https://files.pythonhosted.org/packages/95/c2/ed432272e4948eea9a96323952e52a4a402a449f3ea095a80f9461f9c504/loglito-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-19 21:07:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "loglito",
"github_project": "loglito-python",
"github_not_found": true,
"lcname": "loglito"
}