# LogonTG Python SDK
Simple logging client with uptime monitoring capabilities for LogonTG. Send logs directly to Telegram with smart error batching and LLM-powered analysis.
## Features
- 🚀 **Simple Logging** - Send logs to Telegram in one line
- 📊 **Four Log Levels** - info, error, warning, debug
- 🔍 **Uptime Monitoring** - Automatic error detection and batching (Pro only)
- 🤖 **AI Analysis** - LLM-powered error analysis and insights (Pro only)
- ⚡ **Lightweight** - Minimal dependencies, maximum performance
## Installation
```bash
pip install logontg
```
## Quick Start
```python
from logontg import logontg
# Initialize client
logger = logontg(api_key="your-api-key")
# Send logs
await logger.log("Application started")
await logger.error("Something went wrong!")
await logger.warn("This is a warning")
await logger.debug("Debug information")
# Synchronous versions also available
logger.log_sync("Application started")
logger.error_sync("Database connection failed")
```
## Constructor Options
```python
logger = logontg(
api_key="your-api-key", # Required: Your LogonTG API key
uptime=False, # Optional: Enable uptime monitoring (Pro only)
base_url="http://sruve.com/api", # Optional: API base URL
debug=True # Optional: Enable debug logging
)
```
## Logging Methods
### Async Methods (Recommended)
```python
await logger.log("Info message") # Info level
await logger.error("Error message") # Error level
await logger.warn("Warning message") # Warning level
await logger.debug("Debug message") # Debug level
```
### Sync Methods
```python
logger.log_sync("Info message") # Info level
logger.error_sync("Error message") # Error level
logger.warn_sync("Warning message") # Warning level
logger.debug_sync("Debug message") # Debug level
```
## Uptime Monitoring (Pro Feature)
Enable automatic error detection and AI-powered analysis:
```python
# Enable uptime monitoring
logger = logontg(
api_key="your-api-key",
uptime=True # Requires Pro subscription
)
# Errors are automatically detected and batched
# LLM analysis is sent to Telegram when thresholds are met
```
### Uptime Features:
- **Error Batching** - Groups similar errors over 2-minute windows
- **Smart Thresholds** - Alerts after 3+ similar errors
- **LLM Analysis** - AI-powered error insights and solutions
- **Stack Trace Capture** - Detailed error context
### Manual Control:
```python
# Enable/disable uptime monitoring at runtime
logger.set_uptime_monitoring(True)
logger.set_uptime_monitoring(False)
```
## Message Types
All logging methods accept any data type:
```python
# Strings
await logger.log("Simple string message")
# Dictionaries
await logger.error({
"error": "Database connection failed",
"host": "localhost",
"port": 5432,
"retry_count": 3
})
# Lists
await logger.debug(["step1", "step2", "step3"])
# Any JSON-serializable data
await logger.warn({"users": [1, 2, 3], "active": True})
```
## Error Handling
```python
try:
await logger.log("Test message")
except Exception as e:
if "Rate limit exceeded" in str(e):
print("Upgrade your plan for higher limits")
else:
print(f"Logging failed: {e}")
```
## Examples
### Basic Application Logging
```python
from logontg import logontg
logger = logontg("your-api-key")
# Application lifecycle
await logger.log("🚀 Application starting...")
await logger.log("✅ Database connected")
await logger.log("🌐 Server listening on port 8000")
# Error scenarios
try:
# Some operation
result = risky_operation()
await logger.log(f"✅ Operation completed: {result}")
except Exception as e:
await logger.error(f"❌ Operation failed: {str(e)}")
```
### Web Framework Integration
```python
from flask import Flask
from logontg import logontg
app = Flask(__name__)
logger = logontg("your-api-key")
@app.route("/api/users")
def get_users():
logger.log_sync("📋 Fetching users list")
try:
users = fetch_users()
logger.log_sync(f"✅ Found {len(users)} users")
return {"users": users}
except Exception as e:
logger.error_sync(f"❌ Failed to fetch users: {str(e)}")
return {"error": "Internal server error"}, 500
```
### Monitoring with Context
```python
# Rich logging with context
await logger.log({
"event": "user_registration",
"user_id": 12345,
"email": "user@example.com",
"source": "web_form",
"timestamp": "2024-01-15T10:30:00Z"
})
# Performance monitoring
import time
start = time.time()
# ... some operation ...
duration = time.time() - start
await logger.debug({
"operation": "database_query",
"duration_ms": duration * 1000,
"query": "SELECT * FROM users",
"rows_returned": 150
})
```
## Environment Variables
You can also set your API key via environment variable:
```bash
export LOGONTG_API_KEY="your-api-key"
```
```python
import os
from logontg import logontg
logger = logontg(os.getenv("LOGONTG_API_KEY"))
```
## Requirements
- Python 3.7+
- requests library
## License
MIT License - see LICENSE file for details.
## Support
- 📧 Email: support@sruve.com
- 🌐 Website: https://sruve.com
- 📖 Documentation: https://sruve.com/docs
## Contributing
Contributions welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
---
**LogonTG** - Simple, powerful logging for modern applications.
Raw data
{
"_id": null,
"home_page": "https://github.com/your-username/logontg",
"name": "logontg",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "telegram, logging, notifications, uptime, monitoring, api",
"author": "LogonTG Team",
"author_email": "support@sruve.com",
"download_url": "https://files.pythonhosted.org/packages/88/0b/54f09ee816789b88eac951dc39d063575916cae4c33ca60e7c47b156dadd/logontg-1.0.1.tar.gz",
"platform": null,
"description": "# LogonTG Python SDK\r\n\r\nSimple logging client with uptime monitoring capabilities for LogonTG. Send logs directly to Telegram with smart error batching and LLM-powered analysis.\r\n\r\n## Features\r\n\r\n- \ud83d\ude80 **Simple Logging** - Send logs to Telegram in one line\r\n- \ud83d\udcca **Four Log Levels** - info, error, warning, debug\r\n- \ud83d\udd0d **Uptime Monitoring** - Automatic error detection and batching (Pro only)\r\n- \ud83e\udd16 **AI Analysis** - LLM-powered error analysis and insights (Pro only)\r\n- \u26a1 **Lightweight** - Minimal dependencies, maximum performance\r\n\r\n## Installation\r\n\r\n```bash\r\npip install logontg\r\n```\r\n\r\n## Quick Start\r\n\r\n```python\r\nfrom logontg import logontg\r\n\r\n# Initialize client\r\nlogger = logontg(api_key=\"your-api-key\")\r\n\r\n# Send logs\r\nawait logger.log(\"Application started\")\r\nawait logger.error(\"Something went wrong!\")\r\nawait logger.warn(\"This is a warning\")\r\nawait logger.debug(\"Debug information\")\r\n\r\n# Synchronous versions also available\r\nlogger.log_sync(\"Application started\")\r\nlogger.error_sync(\"Database connection failed\")\r\n```\r\n\r\n## Constructor Options\r\n\r\n```python\r\nlogger = logontg(\r\n api_key=\"your-api-key\", # Required: Your LogonTG API key\r\n uptime=False, # Optional: Enable uptime monitoring (Pro only)\r\n base_url=\"http://sruve.com/api\", # Optional: API base URL\r\n debug=True # Optional: Enable debug logging\r\n)\r\n```\r\n\r\n## Logging Methods\r\n\r\n### Async Methods (Recommended)\r\n```python\r\nawait logger.log(\"Info message\") # Info level\r\nawait logger.error(\"Error message\") # Error level \r\nawait logger.warn(\"Warning message\") # Warning level\r\nawait logger.debug(\"Debug message\") # Debug level\r\n```\r\n\r\n### Sync Methods\r\n```python\r\nlogger.log_sync(\"Info message\") # Info level\r\nlogger.error_sync(\"Error message\") # Error level\r\nlogger.warn_sync(\"Warning message\") # Warning level\r\nlogger.debug_sync(\"Debug message\") # Debug level\r\n```\r\n\r\n## Uptime Monitoring (Pro Feature)\r\n\r\nEnable automatic error detection and AI-powered analysis:\r\n\r\n```python\r\n# Enable uptime monitoring\r\nlogger = logontg(\r\n api_key=\"your-api-key\",\r\n uptime=True # Requires Pro subscription\r\n)\r\n\r\n# Errors are automatically detected and batched\r\n# LLM analysis is sent to Telegram when thresholds are met\r\n```\r\n\r\n### Uptime Features:\r\n- **Error Batching** - Groups similar errors over 2-minute windows\r\n- **Smart Thresholds** - Alerts after 3+ similar errors\r\n- **LLM Analysis** - AI-powered error insights and solutions\r\n- **Stack Trace Capture** - Detailed error context\r\n\r\n### Manual Control:\r\n```python\r\n# Enable/disable uptime monitoring at runtime\r\nlogger.set_uptime_monitoring(True)\r\nlogger.set_uptime_monitoring(False)\r\n```\r\n\r\n## Message Types\r\n\r\nAll logging methods accept any data type:\r\n\r\n```python\r\n# Strings\r\nawait logger.log(\"Simple string message\")\r\n\r\n# Dictionaries\r\nawait logger.error({\r\n \"error\": \"Database connection failed\",\r\n \"host\": \"localhost\",\r\n \"port\": 5432,\r\n \"retry_count\": 3\r\n})\r\n\r\n# Lists\r\nawait logger.debug([\"step1\", \"step2\", \"step3\"])\r\n\r\n# Any JSON-serializable data\r\nawait logger.warn({\"users\": [1, 2, 3], \"active\": True})\r\n```\r\n\r\n## Error Handling\r\n\r\n```python\r\ntry:\r\n await logger.log(\"Test message\")\r\nexcept Exception as e:\r\n if \"Rate limit exceeded\" in str(e):\r\n print(\"Upgrade your plan for higher limits\")\r\n else:\r\n print(f\"Logging failed: {e}\")\r\n```\r\n\r\n## Examples\r\n\r\n### Basic Application Logging\r\n```python\r\nfrom logontg import logontg\r\n\r\nlogger = logontg(\"your-api-key\")\r\n\r\n# Application lifecycle\r\nawait logger.log(\"\ud83d\ude80 Application starting...\")\r\nawait logger.log(\"\u2705 Database connected\")\r\nawait logger.log(\"\ud83c\udf10 Server listening on port 8000\")\r\n\r\n# Error scenarios \r\ntry:\r\n # Some operation\r\n result = risky_operation()\r\n await logger.log(f\"\u2705 Operation completed: {result}\")\r\nexcept Exception as e:\r\n await logger.error(f\"\u274c Operation failed: {str(e)}\")\r\n```\r\n\r\n### Web Framework Integration\r\n```python\r\nfrom flask import Flask\r\nfrom logontg import logontg\r\n\r\napp = Flask(__name__)\r\nlogger = logontg(\"your-api-key\")\r\n\r\n@app.route(\"/api/users\")\r\ndef get_users():\r\n logger.log_sync(\"\ud83d\udccb Fetching users list\")\r\n try:\r\n users = fetch_users()\r\n logger.log_sync(f\"\u2705 Found {len(users)} users\")\r\n return {\"users\": users}\r\n except Exception as e:\r\n logger.error_sync(f\"\u274c Failed to fetch users: {str(e)}\")\r\n return {\"error\": \"Internal server error\"}, 500\r\n```\r\n\r\n### Monitoring with Context\r\n```python\r\n# Rich logging with context\r\nawait logger.log({\r\n \"event\": \"user_registration\",\r\n \"user_id\": 12345,\r\n \"email\": \"user@example.com\", \r\n \"source\": \"web_form\",\r\n \"timestamp\": \"2024-01-15T10:30:00Z\"\r\n})\r\n\r\n# Performance monitoring\r\nimport time\r\nstart = time.time()\r\n# ... some operation ...\r\nduration = time.time() - start\r\n\r\nawait logger.debug({\r\n \"operation\": \"database_query\",\r\n \"duration_ms\": duration * 1000,\r\n \"query\": \"SELECT * FROM users\",\r\n \"rows_returned\": 150\r\n})\r\n```\r\n\r\n## Environment Variables\r\n\r\nYou can also set your API key via environment variable:\r\n\r\n```bash\r\nexport LOGONTG_API_KEY=\"your-api-key\"\r\n```\r\n\r\n```python\r\nimport os\r\nfrom logontg import logontg\r\n\r\nlogger = logontg(os.getenv(\"LOGONTG_API_KEY\"))\r\n```\r\n\r\n## Requirements\r\n\r\n- Python 3.7+\r\n- requests library\r\n\r\n## License\r\n\r\nMIT License - see LICENSE file for details.\r\n\r\n## Support\r\n\r\n- \ud83d\udce7 Email: support@sruve.com\r\n- \ud83c\udf10 Website: https://sruve.com\r\n- \ud83d\udcd6 Documentation: https://sruve.com/docs\r\n\r\n## Contributing\r\n\r\nContributions welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.\r\n\r\n---\r\n\r\n**LogonTG** - Simple, powerful logging for modern applications. \r\n",
"bugtrack_url": null,
"license": null,
"summary": "Python SDK for LogonTG - Simple logging with uptime monitoring",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/your-username/logontg"
},
"split_keywords": [
"telegram",
" logging",
" notifications",
" uptime",
" monitoring",
" api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4988009ea01514efde3dfa0c36815ec3541301f658a1fa54106a6e850600b753",
"md5": "32b237d101da47f6e17526c491c0fffc",
"sha256": "d19280d30932a7b044842cf4200e158b6e6270e93b2adedfd2863ab4f86ed9a4"
},
"downloads": -1,
"filename": "logontg-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "32b237d101da47f6e17526c491c0fffc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7324,
"upload_time": "2025-07-22T21:53:13",
"upload_time_iso_8601": "2025-07-22T21:53:13.185631Z",
"url": "https://files.pythonhosted.org/packages/49/88/009ea01514efde3dfa0c36815ec3541301f658a1fa54106a6e850600b753/logontg-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "880b54f09ee816789b88eac951dc39d063575916cae4c33ca60e7c47b156dadd",
"md5": "a3fd12c0b7223c4e6cd0ae2721dd7bca",
"sha256": "585aff88623349b74bd32bd94ea539d7865440de889c55ef3c7553d50d136a4d"
},
"downloads": -1,
"filename": "logontg-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "a3fd12c0b7223c4e6cd0ae2721dd7bca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 26296,
"upload_time": "2025-07-22T21:53:15",
"upload_time_iso_8601": "2025-07-22T21:53:15.044164Z",
"url": "https://files.pythonhosted.org/packages/88/0b/54f09ee816789b88eac951dc39d063575916cae4c33ca60e7c47b156dadd/logontg-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-22 21:53:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "your-username",
"github_project": "logontg",
"github_not_found": true,
"lcname": "logontg"
}