czim / laravel-context-log-library
该软件包的最新版本(3.1.0)没有可用的许可证信息。
Laravel的上下文日志库
3.1.0
2024-05-29 08:46 UTC
Requires
- php: ^8.1
- czim/laravel-json-context-logging: >=3.0
- illuminate/support: >=10
- psr/log: >=3
Requires (Dev)
- mockery/mockery: ^1.5
- orchestra/testbench: ^8
- phpunit/phpunit: ^10.0
README
Laravel的上下文日志库
czim/laravel-json-context-logging的辅助库,用于标准的配置。
这有助于您快速创建上下文通道以进行日志记录。它不是使用JSON上下文日志的必要条件。
版本兼容性
安装
无需安装;然而,必须在服务提供者中手动绑定类。
<?php use Czim\LaravelContextLogging\Config\StandardJsonContextConfigSource; use Czim\LaravelContextLogging\Contracts\ContextLoggerFactoryInterface; use Czim\LaravelContextLogging\Contracts\DebugEventLogPrepperInterface; use Czim\LaravelContextLogging\Factories\ContextLoggerFactory; class AppServiceProvider extends \Illuminate\Support\ServiceProvider { // ... public function register(): void { $this->app->singleton( DebugEventLogPrepperInterface::class, \Your\JsonContextEventLogPrepper::class ); $this->app->singleton( ContextLoggerFactoryInterface::class, function (): void { $factory = new ContextLoggerFactory(); $factory->setConfigs($this->makeLogContextConfigArray()); return $factory; } ); } protected function makeLogContextConfigArray(): array { return $this->app->make(StandardJsonContextConfigSource::class) ->enableContextLogging() ->makeConfigArray(); } }
您还必须设置自己的事件,该事件可能扩展 Czim\LaravelContextLogging\Events\AbstractDebugEvent
。该事件的监听器应使用 ContextLoggerFactoryInterface
创建记录器,并使用 DebugEventLogPrepperInterface
将事件渲染为可记录的数据。
致谢
许可证
MIT许可证(MIT)。请参阅 许可证文件 了解更多信息。