定制 ch17/blue-log 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ch17/blue-log

Composer 安装命令:

composer require ch17/blue-log

包简介

Laravel log to database

README 文档

README

[ Super simple DB logger, that works! ]

BlueLog is a simple logging package for Laravel that allows you to log messages with context and extra information into both files and a database. It supports logging levels and channels, with precise timestamps down to milliseconds for better debugging and monitoring.

Features

  • Log messages with various levels (debug, info, warning, error etc.)
  • Log to both files and a database
  • Store context and extra information with logs
  • Use millisecond precision for timestamps
  • Configurable log levels
  • Provide pre-defined Service and Facade
  • Store logged in user information as created_by
  • Supports custom channels
  • Super simple plug and play to use

Installation

  1. Require the package via Composer:

    composer require ch17/blue-log
  2. Publish the configuration file and migration:

    php artisan vendor:publish --tag=blue-log-migrations
    php artisan vendor:publish --tag=blue-log-config
  3. Run the migrations:

    php artisan migrate

Configuration

BlueLog's configuration file is located at config/bluelog.php. You can customize the default log level and other settings in this file.

    // Setup default log Channel
    'default_log_channel' => 'Default',

    // Setup default log Level
    // info, debug, error, warning
    'default_log_level' => 'debug',

    // False if authenticated user information should not be stored
    'store_logged_by' => true,

    // add fields want to store for login user as created_by
    'logged_by_fields' => [
        'id',
        'email',
    ],

Usage

To use BlueLog, you can either call the logging methods directly on the BlueLog facade or inject the BlueLogger class into your services.

Logging Methods

BlueLog provides methods for each logging level:

use Ch17\BlueLog\Facades\BlueLog as Log;

   Log::debug('default', 'This is a debug message', ['context' => 'value'], ['extra' => 'value']);
   Log::info('default', 'This is an info message', ['context' => 'value'], ['extra' => 'value']);
   Log::warning('default', 'This is a warning message', ['context' => 'value'], ['extra' => 'value']);
   Log::error('default', 'This is an error message', ['context' => 'value'], ['extra' => 'value']);

Or if its not enough of your style

use Ch17\BlueLog\Facades\BlueLog as Log;

   Log::error([
    'message' => 'a new error message'
   ]);

    Log::warning([
      'channel' => 'user.create',
      'message' => 'a new warning message'
   ]);

With the service:

use Ch17\BlueLog\Services\BlueLogger as logger;

   protected $logger;

    public function __construct(BlueLogger $logger)
    {
        $this->logger = $logger;
    }

Or

use Ch17\BlueLog\Services\BlueLogger as logger;

   $logger = new BlueLogger();
$this->logger->debug('default', 'This is a debug message', ['context' => 'value'], ['extra' => 'value']);
$this->logger->info('default', 'This is an info message', ['context' => 'value'], ['extra' => 'value']);
$this->logger->warning('default', 'This is a warning message', ['context' => 'value'], ['extra' => 'value']);
$logger->info('USER-DELETE', 'User deleted successfully!', ['deletedUser' => json_encode([])], ['extra' => 'value']);

Or

    $logger->error([
    'message' => 'a new error message'
   ]);

    $logger->warning([
      'channel' => 'user.create',
      'message' => 'a new warning message',
      'context' => ['deletedUser' => json_encode($createdUser)]
   ]);

License

ch17/blue-log 适用场景与选型建议

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

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

围绕 ch17/blue-log 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-08