承接 vinkius-labs/watchdog-discord 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vinkius-labs/watchdog-discord

Composer 安装命令:

composer require vinkius-labs/watchdog-discord

包简介

Real-time error monitoring and alerting for Laravel apps via Discord

README 文档

README

Latest Version on Packagist Total Downloads License

Enterprise-grade real-time error monitoring and alerting system for Laravel applications via Discord webhooks.

20250727_1034_Logo Laravel Watchdog_simple_compose_01k15kpqzmfd8bjwgsrdd36nvw

Overview

Watchdog Discord is a high-performance monitoring solution that provides intelligent error tracking, analytics, and instant Discord notifications for Laravel applications. Built with enterprise scalability in mind, it offers Redis-powered error deduplication, severity scoring, and asynchronous processing to ensure zero impact on application performance.

Key Features

  • 🚀 High Performance: Redis-powered error tracking with sub-millisecond performance
  • 🔄 Asynchronous Processing: Queue-based notifications to prevent application slowdown
  • 🎯 Smart Deduplication: Hash-based error grouping and frequency analysis
  • 📊 Error Analytics: Severity scoring, trend detection, and analytics dashboard
  • 🛡️ Rate Limiting: Configurable thresholds to prevent notification spam
  • 🌍 Multi-language Support: Built-in translations for 9 languages
  • 🐳 Docker Ready: Full containerization support for modern deployments

Architecture

Application Layer
├── Exception Handler    ├── Middleware    ├── Facade    ├── Manual Logging
│
Service Layer  
├── Discord Notifier (Central orchestration and payload building)
│
Business Logic Layer
├── Error Tracking Service    ├── Rate Limiter    ├── Queue Manager
│
Data Access Layer
├── Redis Cache    ├── Database (MySQL)    ├── Discord API

The system implements a layered architecture with Redis-first caching, database persistence, and configurable async processing for optimal performance in production environments.

Installation

composer require vinkius-labs/watchdog-discord

Publish Configuration

php artisan vendor:publish --provider="VinkiusLabs\WatchdogDiscord\WatchdogDiscordServiceProvider" --tag="watchdog-discord-config"

Run Migrations

php artisan migrate

Basic Configuration

Environment Setup

# Required
WATCHDOG_DISCORD_ENABLED=true
WATCHDOG_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your/webhook/url

# Performance (Production)
WATCHDOG_DISCORD_ASYNC_ENABLED=true
WATCHDOG_DISCORD_QUEUE_CONNECTION=redis
WATCHDOG_DISCORD_CACHE_PREFIX=watchdog_prod

# Error Tracking
WATCHDOG_DISCORD_ERROR_TRACKING_ENABLED=true
WATCHDOG_DISCORD_MIN_SEVERITY=7
WATCHDOG_DISCORD_FREQUENCY_THRESHOLD=10

# Rate Limiting
WATCHDOG_DISCORD_RATE_LIMIT_ENABLED=true
WATCHDOG_DISCORD_RATE_LIMIT_MAX=20
WATCHDOG_DISCORD_RATE_LIMIT_WINDOW=5

Discord Webhook Setup

  1. Navigate to your Discord server settings
  2. Go to IntegrationsWebhooks
  3. Create a new webhook and copy the URL
  4. Add the URL to your .env file

Usage

Automatic Error Handling

The package automatically captures and reports Laravel exceptions through the exception handler integration.

Manual Logging

use VinkiusLabs\WatchdogDiscord\Facades\WatchdogDiscord;

// Log exceptions with context
try {
    $result = $riskyOperation->execute();
} catch (\Exception $e) {
    WatchdogDiscord::send($e, 'error', [
        'operation' => 'payment_processing',
        'user_id' => auth()->id()
    ]);
    throw $e;
}

// Log custom messages
WatchdogDiscord::sendLog('warning', 'High memory usage detected', [
    'memory_usage' => memory_get_usage(true),
    'peak_memory' => memory_get_peak_usage(true)
]);

Log Levels Support

The package supports all PSR-3 log levels with intelligent severity scoring:

// Emergency level (severity: 10)
WatchdogDiscord::emergency('Database server down');

// Alert level (severity: 9)  
WatchdogDiscord::alert('Payment gateway unreachable');

// Critical level (severity: 8)
WatchdogDiscord::critical('Application crashed');

// Error level (severity: 6)
WatchdogDiscord::error('User authentication failed');

// Warning level (severity: 4)
WatchdogDiscord::warning('High memory usage');

// Notice level (severity: 2)
WatchdogDiscord::notice('New admin user created');

// Info level (severity: 1) 
WatchdogDiscord::info('Backup completed successfully');

// Debug level (severity: 1)
WatchdogDiscord::debug('Cache warming started');

Configuration: Control which log levels are sent to Discord:

# Production (critical issues only)
WATCHDOG_DISCORD_LOG_LEVELS=emergency,alert,critical,error
WATCHDOG_DISCORD_MIN_SEVERITY=7

# Development (all levels)
WATCHDOG_DISCORD_LOG_LEVELS=emergency,alert,critical,error,warning,notice,info,debug  
WATCHDOG_DISCORD_MIN_SEVERITY=1

Middleware Integration

// Apply to specific routes
Route::middleware('watchdog-discord:error')->group(function () {
    Route::post('/api/payments', [PaymentController::class, 'process']);
});

// Global middleware (app/Http/Kernel.php)
protected $middleware = [
    \VinkiusLabs\WatchdogDiscord\Middleware\WatchdogDiscordMiddleware::class,
];

Dependency Injection

use VinkiusLabs\WatchdogDiscord\DiscordNotifier;

class PaymentService
{
    public function __construct(
        private DiscordNotifier $notifier
    ) {}
    
    public function processPayment($data)
    {
        try {
            return $this->gateway->charge($data);
        } catch (\Exception $e) {
            $this->notifier->send($e, 'critical', [
                'payment_data' => $data,
                'gateway' => $this->gateway->getName()
            ]);
            throw $e;
        }
    }
}

Performance Optimization

Redis Configuration

For optimal performance, configure Redis connection:

// config/database.php
'redis' => [
    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_DB', '0'),
    ],
],

Queue Workers

Configure dedicated queue workers for notifications:

# Supervisor configuration
php artisan queue:work redis --queue=watchdog_notifications --sleep=3 --tries=3

Production Settings

# Optimal production configuration
WATCHDOG_DISCORD_ASYNC_ENABLED=true
WATCHDOG_DISCORD_QUEUE_CONNECTION=redis
WATCHDOG_DISCORD_CACHE_TTL=300
WATCHDOG_DISCORD_ERROR_TRACKING_ENABLED=true
WATCHDOG_DISCORD_RATE_LIMIT_ENABLED=true

Testing

# Test Discord notifications
php artisan watchdog-discord:test --exception

# Test with custom message
php artisan watchdog-discord:test --level=error --message="Test notification"

# Run test suite
composer test

# Code analysis
composer analyse

Documentation

Requirements

  • PHP: 8.1, 8.2, or 8.3
  • Laravel: 9.x, 10.x, 11.x, or 12.x
  • Redis: 6.0+ (recommended for production)
  • MySQL: 5.7+ or 8.0+

Security

If you discover a security vulnerability, please send an email to VinkiusLabs at labs@vinkius.com. All security vulnerabilities will be promptly addressed.

License

The MIT License (MIT). Please see License File for more information.

Credits

Built with ❤️ by Vinkius Labs

vinkius-labs/watchdog-discord 适用场景与选型建议

vinkius-labs/watchdog-discord 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.71k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「notifications」 「alerts」 「monitoring」 「laravel」 「webhook」 「discord」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vinkius-labs/watchdog-discord 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vinkius-labs/watchdog-discord 我们能提供哪些服务?
定制开发 / 二次开发

基于 vinkius-labs/watchdog-discord 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-27