定制 smcrow/laravel-slack-log 二次开发

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

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

smcrow/laravel-slack-log

Composer 安装命令:

composer require smcrow/laravel-slack-log

包简介

Utilizes Laravel's notifications to provide logging to slack at various levels. Inspired by Log4j.

README 文档

README

Latest Stable Version Latest Unstable Version Total Downloads Build Status

This package utilizes Laravel's native ability to create slack notifications to log at different log levels. This was inspired by Log4j.

Log Levels

There are several different log levels that can be used. The desired level of logging is defined in the config.

Here are some example uses of the different log levels:

  • ERROR - Indicates that an error occured.
  • WARN - Indicates that an error occured but it was recoverable.
  • INFO - Informational message usually explaining something in a business rule sense.
  • TRACE - Used for reporting where, in the code, the execution is taking place. Could report entering and leaving functions.
  • DEBUG - Used for dumping the contents of a variable.

Each message is implemented in the same way. The log levels are for you, the developer, to decide how to use.

The configured log level is checked before the message is sent. Levels are inclusive in that a specific level will include all message levels above it. For example, INFO will include INFO, WARN, and ERROR.

In some cases, it can be non-trivial to generate the message string. Logging guards have been provided to assist with this.

Installation Steps

Install Through Composer

composer require smcrow/laravel-slack-log

Register the Service Provider

Laravel 5.5

Laravel 5.5 allows for the auto-discovery of service providers. The SlackLogServiceProvider will automatically be discovered.

Pre Laravel 5.5

You'll need to register the command in order for it to be usable. Modify the register method of AppServiceProvider:

public function register()
{
    $this->app->register(SlackLogServiceProvider::class);
}

Registering the Facade

You can register the optional facade by adding the following to your app.php aliases:

'SlackLog' => \Smcrow\SlackLog\Facades\SlackLog::class

Configuration

Use php artisan vendor:publish to create a new configuration file. The file will be config/slack-log.php.

In this file you will need to provide the webhook url. I recommend reading Slack Incoming Webhooks for more information on how to setup the webhook.

Example Usage

With logging guards and using the facade:

$user = ['name' => 'John', 'age' => 65];

if (SlackLog::isDebugEnabled()) {
    SlackLog::debug('User: ' . print_r($user, true));
}

Produces the following:

Debug Example

Feedback and Contributions

Please feel free to offer suggestions by submitting an Issue. Alternatively, submit a pull request with any features you wish to add. This is a work-in-progress, and I would welcome any and all feedback.

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固