ssch / t3-psr3-log-processor
提供 PSR-3 交插日志处理器
v1.0.0
2023-03-16 22:19 UTC
Requires
- php: ^7.4 || ^8.0
- typo3/cms-core: ^10.4 || ^11.5 || ^12.1
Requires (Dev)
Replaces
- typo3-ter/t3-psr3-log-processor: v1.0.0
This package is auto-updated.
Last update: 2024-08-31 00:42:45 UTC
README
https://www.php-fig.org/psr/psr-3/#12-message
集成指南
该扩展附带一个自定义处理器,用于将日志消息中的上下文变量替换为消息。假设您有一个以下格式的日志消息
use Psr\Log\LogLevel;use TYPO3\CMS\Core\Log\LogRecord; $logRecord = new LogRecord('foo', LogLevel::INFO, 'A message with a {placeholder}', ['placeholder' => 'bar']);
在这种情况下,消息的 {占位符} 将在扩展提供的 PsrLogProcessor 处理时被 "bar" 替换。
为了激活处理器,您可以通过 ext_localconf.php 进行配置,例如
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Documentation']['Examples']['Controller']['processorConfiguration'] = [ // configuration for Debug level log entries and above \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [ \Ssch\Psr3LogProcessor\Processor\PsrLogMessageProcessor::class => [ // The format of the timestamp: one supported by DateTime::format 'dateFormat' => DateTime::ISO8601, // If set to true the fields interpolated into message gets unset 'removeUsedContextFields' => true, // Arrays will be json encoded. With this option you can define how this will happen 'jsonFlags' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ] ] ];
致谢
此日志处理器深受 monolog/monolog 处理器的影响。