bkstar123/log-enhancer 问题修复 & 功能扩展

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

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

bkstar123/log-enhancer

Composer 安装命令:

composer require bkstar123/log-enhancer

包简介

This package enhances Laravel logging feature

README 文档

README

1.Requirements

It is recommended to install this package with PHP version 7.1.3+ and Laravel Framework version 5.6+

2.Installation

composer require bkstar123/log-enhancer 

3.Usage

By default, the package will use a custom channel named as bkstar123_log_enhancer and write log messages to a file named as laravel-bkstar123_log_enhancer-YYYY-MM-DD.log. The default log driver is daily and rotation period is 7 days.

You can customize the base name of log files and the rotation period by adding the following environment settings in .env file:

  • BKSTAR123_LOG_ENHANCER_LOG_NAME
  • BKSTAR123_LOG_ENHANCER_DAYS_FOR_ROTATION (in days)

It is not necessary but you can also change the custom channel name with BKSTAR123_LOG_ENHANCER_CHANNEL setting in .env file

You can also write custom log messages to browser Javascript console with no browser extension required. Most browsers supporting console API are supported

To do so, just add the following environment setting in .env file:
BKSTAR123_LOG_ENHANCER_TO_BROWSER_CONSOLE=true

To write a log message, call to log() method of DebugLog facade as follows:
DebugLog::log($level = '', string $message = '', array $context = [])

Note: DebugLog alias is automatically registered, so you do not need to add it in the config/app.php

where $level can be debug|info|notice|warning|error|critical|emergency (default to debug level)

Example:

DebugLog::log('info', "Hello {n}", ['n' => 'Antony Hoang'])

Log messages are enhanced with the following data:

datetime (with the system timezone): date and time of log messages
channel: value of APP_ENV setting in .env file
level_name: value of $level
message: your custom log message
pid: the process ID of the PHP thread serving the current request
client_ip: the IP address of the client browser
url: request path
http_method: HTTP verb of the current request e.g: GET, POST ...
route_hanlder: the name of the request route handler i.e ControllerName/ActionName
session: the session data associated with the request

Sample log message:

[2019-06-08 11:08:43 UTC] [local.INFO]: Hello Antony Hoang
{'pid': '2873', 'client_ip': '192.168.1.35', 'url': '/', 'http_method': 'GET', 'route_handler': 'App\Http\Controllers\TestController@test', 
'session': {"_token":"aSKrQ8xXETX5Mywt3EoLMqTG6SfOA6M4Vc5yGyDC","_previous":{"url":"http://kpacks.acme.com"},"_flash":{"old":[],"new":[]}}}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固