承接 ch17/blue-log 相关项目开发

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

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

ch17/blue-log

最新稳定版本:v2.0.0

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

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固