salvegame197/laravel-mongodb-logging 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

salvegame197/laravel-mongodb-logging

Composer 安装命令:

composer require salvegame197/laravel-mongodb-logging

包简介

Logging to Mongodb using Laravel logging

README 文档

README

This package gives opportunity logging to mongodb with custom Laravel logging

Package jenssegers/laravel-mongodb is required

##UPDATED LARAVEL 8

Installation

composer require salvegame197/laravel-mongodb-logging

Configuration

Add configurations to file ..\your_project\config\logging.php

'mogodb-channel' => [
            'driver' => 'custom',
            'via' => \Nechaienko\MongodbLogging\LogToMongoDb::class,
            'level' => 'info',
            'connection' => 'mongodb',
            'collection' => 'logs',         
        ],

Customization

Additional fields

'mogodb-channel' => [
            ...
            'additional_fields' => [
                'environment' => config('app.env'),
                ...
            ],         
        ],

Fields formatting

You can override model from package and change fields format with Laravel mutators

  1. Create your model and override needed method
namespace App\Services\Logging;

use Nechaienko\MongodbLogging\MongoDbModel as ParentMongoDbModel;

class MongoDbModel extends ParentMongoDbModel
{
    public function setDatetimeAttribute($value)
    {
        ...
        $this->attributes['datetime'] = $resultValue;
    }
}
  1. Add your model to confs
'mogodb-channel' => [
            ...
            'custom_model' => \App\Services\Logging\MongoDbModel::class,         
        ],

Set default fields

You can define fields to set by overriding constant FIELDS_TO_SET

namespace App\Services\Logging;

use Nechaienko\MongodbLogging\MongoDbModel as ParentMongoDbModel;

class MongoDbModel extends ParentMongoDbModel
{
    public const FIELDS_TO_SET = [
        'message',
        'level_name',
        'datetime',
        'extra',
    ];
}

Usage

use Illuminate\Support\Facades\Log;
...
Log::channel('mogodb-channel')->info('message');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-05-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固