定制 consigliere/signal 二次开发

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

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

consigliere/signal

Composer 安装命令:

composer require consigliere/signal

包简介

README 文档

README

Laravel signal
v5.4 ~0.2
v5.5 ~0.3
v5.7 ~0.8
v5.8 ~1.0

The logger provides the eight logging levels defined in RFC 5424: emergency, alert, critical, error, warning, notice, info and debug. Passing message into event and It will automatically detect request url, request method, client ip, browser, brower version, user OS etc and save it into database. The log data can be sent to user email by changing the configuration setting in config file.

Install

composer require consigliere/signal

Migration

php artisan vendor:publish --tag=migrations-signal
php artisan migrate

Publish config

php artisan vendor:publish --tag=config-signal

Basic

Signal - using event helper

event('signal.emergency', [$message]);
event('signal.alert', [$message,]);
event('signal.critical', [$message]);
event('signal.error', [$message]);
event('signal.warning', [$message]);
event('signal.notice', [$message]);
event('signal.info', [$message]);
event('signal.debug', [$message]);

Signal - Using Event Facade

use Illuminate\Support\Facades\Event;

Event::dispatch('signal.emergency', [$message]);
Event::dispatch('signal.alert', [$message]);
Event::dispatch('signal.critical', [$message]);
Event::dispatch('signal.error', [$message]);
Event::dispatch('signal.warning', [$message]);
Event::dispatch('signal.notice', [$message]);
Event::dispatch('signal.info', [$message]);
Event::dispatch('signal.debug', [$message]);

Events Wrapper

In the config, log.activity and specific logging control needs to be set as true.

Wrapper

$this->fireLog('emergency', $message);
$this->fireLog('alert', $message);
$this->fireLog('critical', $message);
$this->fireLog('error', $message);
$this->fireLog('warning', $message);
$this->fireLog('notice', $message);
$this->fireLog('info', $message);
$this->fireLog('debug', $message);

Code Example

use App\Components\Signal\Traits\Signal;

class UserController extends Controller
{
    use Signal;

    public function browse(Request $request): \Illuminate\Http\JsonResponse
    {
        $data   = [];
        $option = $this->getOption();
        $param  = $this->getParam($this->type);

        try {
            $user = $this->userService->profile($data, $option, $param);
        } catch (\Exception $error) {
            # Provide $error instance of \Exception
            # Provide the uuid, upon empty, error uuid will be assigned automatically
            $this->fireLog('error', $error->getMessage(), ['error' => $error, 'uuid' => $this->euuid]);

            return $this->response($this->getErrorResponse($this->euuid, $error), 500);
        }

        return $this->response($user, 200);
    }
}

Signal Api Response error reporting example

Sent log data into multiple email recipient

Make sure the application can send an email by providing the correct data in .env.

MAIL_DRIVER=
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=

Set the LOG_ACTIVITY and SIGNAL_EMAIL_SENT value to true in .env. Provide user email data where it will be sent separated by a comma.

LOG_ACTIVITY=true
SIGNAL_EMAIL_SENT=true
SIGNAL_EMAIL_SENT_TO=email1@example.com,email2@example.com,etc@example.com
SIGNAL_USE_TABLE=signal_log

MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-06-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固