定制 communitales/log 二次开发

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

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

communitales/log

最新稳定版本:3.2.0

Composer 安装命令:

composer require communitales/log

包简介

Communitales Log Component

关键字:

README 文档

README

Convenient integration for logging of messages and exceptions.

Setup

Just use the LogAwareTrait.

Then set a logger via $this->setLogger($logger); or use the Psr\Log\LoggerAwareInterface as marker interface to let the Dependency Injection do the magic for you.

Symfony example:

services:

    _instanceof:
        Psr\Log\LoggerAwareInterface:
            calls:
                - [setLogger, ['@logger']]

Usage


use App\Component\Log\LogAwareTrait;
use Psr\Log\LoggerAwareInterface;
use \RuntimeException;

class SomeClass implements LoggerAwareInterface
{

    use LogAwareTrait;

    public function testLog(): void
    {
        // Log your message including debug information
        $this->log('Test message', LogLevel::DEBUG, ['param1' => 'useful debug information']);

        // Log an error
        $this->log('This should not happen');
    }

    public function testLogException(): void
    {
        try {
            throw new RuntimeException('Something gone wrong');
        } catch (RuntimeException $exception) {

            // Log with one line
            $this->logException($exception);
        }

    }
}

Sentry logging out of the box

If the \Sentry\captureException function is available, exceptions will be logged also to Sentry.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-29