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
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-29