arielblackymetal/endpoint-logger
最新稳定版本:v2.2.0
Composer 安装命令:
composer require arielblackymetal/endpoint-logger
包简介
Un driver de logging de Laravel para enviar logs a un endpoint.
README 文档
README
A Laravel logging driver package for sending logs to a centralized endpoint with support for custom business reporting levels.
Features
- Custom driver for Laravel Logging
- Automatic log sending to HTTP endpoint
- Standard logging levels (debug, info, warning, error, critical)
- NEW: Custom levels for business reporting
- WebProcessor included for additional web context information
Custom Levels Available
The package includes custom levels designed for business reporting:
- INVOICE (250) - For billing-related logs
Installation
- Install the package via Composer:
composer require arielblackymetal/endpoint-logger
- The ServiceProvider will be automatically registered in Laravel.
Configuration
Add a channel in your config/logging.php file:
'channels' => [ // ... existing channels ... 'ax1-info' => [ 'driver' => 'endpoint', 'url' => 'https://your-endpoint.com/api/logs', 'level' => 'debug', // Minimum level to capture all logs ], 'ax1-invoice' => [ 'driver' => 'endpoint', 'url' => 'https://your-endpoint.com/api/logs', 'level' => 'invoice', // Only captures invoice level and above ], ],
Usage
Standard Levels
Log::channel('ax1-info')->info('Information message'); Log::channel('ax1-info')->error('System error'); Log::channel('ax1-info')->warning('Important warning');
Custom Business Levels
// Invoice Log::channel('ax1-info')->invoice('Sales report generated', ['count' => 2, 'amount' => 150.00]);
Payload Structure
Each log sent to the endpoint includes:
{
"severity": 250,
"log_type": "INVOICE",
"message": "Invoice transmitted",
"context": {
"count": 2,
"amount": 150.00
},
"app_name": "My Application",
"ocurred_at": "2024-01-15T10:30:00+00:00",
"metadata": {
// Additional web context information
}
}
Benefits of Custom Levels
- Smart Filtering: Configure channels that only capture specific types of business logs
- Specific Reporting: Generate reports based on specific event types
- Business Monitoring: Separate technical logs from business logs
- Advanced Analytics: Enable granular analysis of different business aspects
Advanced Configuration Examples
Invoice-Only Channel
'ax1-invoice-only' => [ 'driver' => 'endpoint', 'url' => 'https://your-endpoint.com/api/invoices', 'level' => 'invoice', // Only captures invoice logs ],
Channel for All Business Events
'ax1-business' => [ 'driver' => 'endpoint', 'url' => 'https://your-endpoint.com/api/business', 'level' => 'invoice', // Captures invoice and all levels above ],
Requirements
- PHP >= 8.1
- Laravel >= 10.0
- Monolog >= 3.0
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-08-15