承接 laikmosh/plog 相关项目开发

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

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

laikmosh/plog

Composer 安装命令:

composer require laikmosh/plog

包简介

Advanced Laravel logging system with metadata capture, tagging, and powerful filtering

README 文档

README

Plog is a powerful Laravel logging enhancement package that captures extensive metadata, supports tagging, and provides an interactive web interface for log exploration.

Features

  • Automatic Metadata Capture: User ID, Session ID, Request ID, file/line, class/method
  • Request Tracking: Track logs across HTTP requests, queued jobs, and CLI commands
  • Tagging System: Organize logs with tags for easy filtering
  • Interactive Web Interface: Filter, search, and explore logs with Livewire + Alpine.js
  • Flexible Storage: SQLite by default, configurable to any Laravel database
  • Granular Retention: Configure different retention periods for different log types

Installation

composer require laikmosh/plog

Configuration

Publish the configuration file and assets:

php artisan vendor:publish --tag=plog-config
php artisan vendor:publish --tag=plog-assets

Run migrations:

php artisan migrate

Environment Variables

# Enable/disable Plog
PLOG_ENABLED=true

# Authorized emails (comma-separated)
PLOG_AUTHORIZED_EMAILS=admin@example.com,developer@example.com

# Database connection (optional, defaults to SQLite)
PLOG_DB_CONNECTION=plog

# Default retention period
PLOG_RETENTION_DAYS=7

# Enable automatic cleanup
PLOG_CLEANUP_ENABLED=true

Usage

Basic Logging

All existing Laravel log calls automatically capture metadata:

Log::info('User logged in', ['user_id' => $user->id]);
Log::error('Payment failed', ['order_id' => $orderId]);

Using Tags

You can add tags to organize and filter your logs. Tags work seamlessly with Laravel's standard Log facade:

use Illuminate\Support\Facades\Log;

// Add tags using the special '_tags' key in the context array
Log::info('Order processed', [
    'order_id' => $orderId,
    '_tags' => ['payment', 'stripe']
]);

Log::error('Connection failed', ['_tags' => ['database', 'error']]);

Log::warning('Slow query', [
    'time' => 2.5,
    '_tags' => ['performance', 'database']
]);

// The _tags key is automatically extracted and stored separately
// It won't appear in your logged context data

This approach works with ALL Laravel log methods and doesn't require any changes to existing code. Just add '_tags' => ['tag1', 'tag2'] to your context array when needed.

Viewing Logs

Access the web interface at /logs (requires authentication and authorization).

The interface allows you to:

  • Filter by level, user, request ID, session, environment, endpoint, and tags
  • Search through log messages and context
  • Click any field to instantly filter by that value
  • View detailed log entries with full context
  • Group logs by request to trace execution flow

Advanced Configuration

Custom Database Connection

In config/plog.php:

'database' => [
    'connection' => 'mysql', // Use your app's main database
    'table' => 'plog_entries',
],

Retention Policies

Configure granular retention rules:

'retention' => [
    'default_days' => 7,
    'rules' => [
        ['tags' => ['payment'], 'days' => 30],
        ['tags' => ['authentication'], 'days' => 90],
        ['level' => 'error', 'days' => 14],
    ],
],

Authorization

Control access via email whitelist:

'authorized_emails' => [
    'admin@example.com',
    'developer@example.com',
],

Or customize the gate in your AuthServiceProvider:

Gate::define('viewPlog', function ($user) {
    return $user->hasRole('admin');
});

Request ID Tracking

Plog automatically generates and tracks request IDs across:

  • HTTP requests
  • Queued jobs (preserves original request ID)
  • CLI commands

Access the current request ID:

use Laikmosh\Plog\Services\RequestIdService;

$requestId = app(RequestIdService::class)->getRequestId();

Captured Metadata

Each log entry captures:

  • Time: Timestamp with microseconds
  • Level: debug, info, notice, warning, error, critical, alert, emergency
  • Message: Log message
  • Context: Additional data passed to the log
  • User ID: Currently authenticated user
  • Session ID: Current session identifier
  • Request ID: Unique request identifier
  • Environment: http, cli, queue, testing
  • Endpoint: Route name or URI, CLI command
  • File & Line: Source code location
  • Class & Method: Calling class and method
  • Tags: Custom tags for organization

Performance Considerations

  • Logs are written synchronously by default
  • Consider using a dedicated database for high-volume applications
  • Indexes are automatically created for common query patterns
  • Use retention policies to manage database size

License

MIT

laikmosh/plog 适用场景与选型建议

laikmosh/plog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 53 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 laikmosh/plog 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-29