tailstream-io/laravel-logger
Composer 安装命令:
composer require tailstream-io/laravel-logger
包简介
A beautiful Laravel log driver package with performance monitoring, request tracking, and cache-based batching
README 文档
README
A beautiful Laravel log driver package with performance monitoring, request tracking, and cache-based batching capabilities. Built with Laravel 12+ compatibility and following convention over configuration principles.
About Tailstream
Tailstream is a modern log aggregation and monitoring platform designed for developers who need powerful observability without the complexity. It provides real-time log streaming, intelligent alerting, and beautiful dashboards to help you monitor your applications effectively.
✨ Features
- 🚀 Minimal Configuration - Works with just basic setup
- ⚡ Performance Monitoring - Track response times and memory usage
- 🔗 Request Correlation - UUID-based request tracking across your application
- 📦 Smart Batching - Cache-based log batching with configurable thresholds
- 🚀 Queue Support - Optional asynchronous processing via Laravel queues
- 🎯 Tailstream Integration - Direct integration with Tailstream API
- 🛡️ Laravel 12 Native - Built using Laravel 12's modern patterns and conventions
- 🧪 Comprehensive Tests - Full Pest test suite with 100% coverage
🚀 Installation
composer require tailstream-io/laravel-logger
Configure Stream Credentials
Add your stream credentials to your .env file:
TAILSTREAM_STREAM_UUID=your-stream-uuid TAILSTREAM_STREAM_SECRET=your-stream-secret
That's it! The package will automatically:
- Register itself via Laravel's package discovery
- Add global middleware to track all requests
- Start sending request data to Tailstream immediately
📋 Quick Start
Your application is now automatically sending request data to Tailstream! All HTTP requests will be tracked and batched for efficient delivery.
⚙️ Configuration
While the package requires minimal configuration to get started, you can customize it further:
php artisan vendor:publish --tag=tailstream-logger-config
Environment Variables
# Basic Settings TAILSTREAM_ENABLED=true TAILSTREAM_BASE_URL=https://app.tailstream.io/api TAILSTREAM_SAMPLING_RATE=1.0 TAILSTREAM_INSTANCE_ID=web-01 # Batching Configuration TAILSTREAM_BATCH_SIZE=50 # Flush when batch reaches this size TAILSTREAM_FLUSH_FREQUENCY=10 # Flush every N requests TAILSTREAM_CACHE_TTL=3600 # Queue Configuration (Optional) TAILSTREAM_USE_QUEUE=false # Enable asynchronous processing TAILSTREAM_QUEUE_NAME=tailstream # Queue name for processing TAILSTREAM_QUEUE_CONNECTION= # Queue connection (default: app default) # Middleware TAILSTREAM_AUTO_MIDDLEWARE=true
📊 What Gets Logged
Data is sent in batches to the Tailstream ingest endpoint (https://app.tailstream.io/api/ingest/{stream_uuid}) with Bearer token authentication using NDJSON format:
{"ts":"2024-03-15T10:30:45.123456+00:00","host":"web-01","path":"/api/users","method":"GET","status":200,"rt":0.245,"bytes":1024,"src":"192.168.1.100"}
{"ts":"2024-03-15T10:31:12.789012+00:00","host":"web-01","path":"/api/posts","method":"POST","status":201,"rt":0.156,"bytes":512,"src":"192.168.1.101"}
Field Descriptions
- ts: ISO 8601 timestamp when the request was processed
- host: Server hostname where the request was handled
- path: Request path (without query parameters)
- method: HTTP method (GET, POST, etc.)
- status: HTTP response status code
- rt: Response time in seconds
- bytes: Response size in bytes
- src: Client IP address
🔧 Advanced Configuration
Queue-Based Processing
For high-traffic applications, you can enable asynchronous processing using Laravel queues. This prevents the HTTP request from being blocked while logs are sent to Tailstream:
TAILSTREAM_USE_QUEUE=true TAILSTREAM_QUEUE_NAME=tailstream TAILSTREAM_QUEUE_CONNECTION=redis
When queue processing is enabled:
- Log batches are dispatched to the specified queue instead of being sent synchronously
- The queue job includes retry logic (3 attempts with 60-second backoff)
- Your queue workers will handle the actual transmission to Tailstream
- This reduces request latency and provides better fault tolerance
Requirements:
- Ensure your queue system is properly configured and running
- Queue workers must be active to process the jobs
- Consider using a reliable queue driver like Redis or database for production
Sampling for High-Traffic Apps
'sampling_rate' => 0.1, // Log 10% of requests
Exclude Specific Paths
'excluded_paths' => [ 'telescope/*', 'horizon/*', '_ignition/*', 'health-check', 'up', 'favicon.ico', '*.css', '*.js', '*.map', 'storage/*', ],
🧪 Testing
composer test
📚 Laravel Integration
Middleware Registration
The package automatically registers middleware globally. To disable:
'auto_register_middleware' => false,
Then manually register:
// bootstrap/app.php ->withMiddleware(function (Middleware $middleware) { $middleware->append(TailstreamLogger::class); })
🔍 Monitoring & Debugging
Request Correlation
Every request gets a unique UUID that's included in all logs during that request, making it easy to trace issues across your application.
📈 Batching Strategy
- Batch Size: Process when 50 entries are collected (configurable)
- Periodic Flush: Process every 10 requests to prevent logs sitting too long (configurable)
- Cache-Based: Uses your configured cache driver (Redis recommended)
- Queue Support: Optional asynchronous processing for high-traffic applications
🔧 Management Commands
The package includes artisan commands for batch management:
# Check batch status php artisan tailstream:flush --status # Manually flush pending logs php artisan tailstream:flush # Clear batch without processing php artisan tailstream:flush --clear
📝 License
This package is open-sourced software licensed under the MIT license.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
🐛 Bug Reports
If you discover a bug, please open an issue on GitHub.
tailstream-io/laravel-logger 适用场景与选型建议
tailstream-io/laravel-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「performance」 「monitoring」 「middleware」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tailstream-io/laravel-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tailstream-io/laravel-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tailstream-io/laravel-logger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
g4 application profiler package
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
A Symfony bundle for chameleon-system/sanitycheck
WordPress mu-plugin to remove jQuery Migrate from the list of jQuery dependencies and to allow jQuery to enqueue before </body> instead of in the <head>.
Create link to static resources with cache-breaking segment based on md5 of the file
A Zend Framework module that sets up Monolog for logging in applications.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-27