Project

General

Profile

Actions

Bug #104563

closed

Use classname instead of ID for getLogger in LoggerAwarePass

Added by Stefan Froemken 4 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Logging
Target version:
Start date:
2024-08-07
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
8.3
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

Hello,

in my Services.yaml I have added following lines:

services:
  TYPO3\CMS\Core\Database\ConnectionPool: ~

  db.connection.default:
    class: TYPO3\CMS\Core\Database\Connection
    factory: ['@TYPO3\CMS\Core\Database\ConnectionPool', 'getConnectionByName']
    arguments: ['%default_connection_name%']

As class "Connection" includes the "LoggerAwareTrait", that class will be looped within the "LoggerAwarePass".

There you have following lines:

$channel = $id;
if ($definition->getClass()) {
    $reflectionClass = $container->getReflectionClass($definition->getClass(), false);
    if ($reflectionClass) {
        $channel = $this->getClassChannelName($reflectionClass) ?? $channel;
    }
}

Please remember that $id is "db.connection.default" here which is not helpful for Logger. I prefer using the classname out of Definition:

$channel = $id;
if ($definition->getClass()) {
    $reflectionClass = $container->getReflectionClass($definition->getClass(), false);
    if ($reflectionClass) {
        $channel = $this->getClassChannelName($reflectionClass) ?? $definition->getClass();
    }
}

That way the logger was build up correctly again with a classname

Stefan

Actions

Also available in: Atom PDF