<?php

namespace Codappix\CdxLogging;

use TYPO3\CMS\Core\Log\LogRecord;
use TYPO3\CMS\Core\Log\Processor\AbstractProcessor;
use TYPO3\CMS\Core\Log\Processor\ProcessorInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class UriProcessor extends AbstractProcessor implements ProcessorInterface
{
    public function processLogRecord(LogRecord $logRecord)
    {
        $logRecord->addData([
            'URI' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'),
        ]);
        return $logRecord;
    }
}

$GLOBALS['TYPO3_CONF_VARS']['LOG']['das']['writerConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
        \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
            'logFileInfix' => 'das',
        ],
    ],
];
$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::WARNING => [
        \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
            'logFileInfix' => 'warn',
        ],
    ],
];
$GLOBALS['TYPO3_CONF_VARS']['LOG']['processorConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
        \Codappix\CdxLogging\UriProcessor::class => [
        ],
    ],
];
$GLOBALS['TYPO3_CONF_VARS']['LOG']['TYPO3']['CMS']['deprecations']['writerConfiguration'] = [
    \TYPO3\CMS\Core\Log\LogLevel::NOTICE => [
        \TYPO3\CMS\Core\Log\Writer\FileWriter::class => [
            'logFileInfix' => 'deprecation',
        ],
    ],
];
